当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。