當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Processing keyPressed用法及代碼示例

Processing, keyPressed用法介紹。

說明

如果按下任何鍵,布爾係統變量keyPressedtrue,如果沒有按下任何鍵,則為false



請注意,有一個類似名稱的函數,稱為 keyPressed() 。有關更多信息,請參見其參考頁。

例子

// Click on the image to give it focus,
// and then press any key.

// Note: The rectangle in this example may 
// flicker as the operating system may 
// register a long key press as a repetition
// of key presses.

void draw() {
  if (keyPressed == true) {
    fill(0);
  } else {
    fill(255);
  }
  rect(25, 25, 50, 50);
}

相關用法


注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 keyPressed。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。