首页 > 文档 > keyCode特殊键键值
2017
07-14

keyCode特殊键键值

2-2.keyCode

Name(名称):keyCode//可变密钥是用来检测键盘特殊键。

Examples(例子):

color fillVal = color(126);

void draw() {

fill(fillVal);

rect(25, 25, 50, 50);

}

void keyPressed() {

if (key == CODED) {

if (keyCode == UP) {

fillVal = 255;

} else if (keyCode == DOWN) {

fillVal = 0;

}

} else {

fillVal = 126;

}

}

Description(描述):The variable keyCode is used to detect special keys such as the arrow keys (UP, DOWN, LEFT, and RIGHT) as well as ALT, CONTROL, and SHIFT.

可变密钥是用来检测(箭头键,下来,左,右)以及ALT、控制和转移等特殊键。

When checking for these keys, it can be useful to first check if the key is coded. This is done with the conditional if (key == CODED), as shown in the example above.

在检查这些密钥时,首先检查密钥是否被编码是有用的。这是用条件if(键= =编码)完成的,如上面的示例所示。

The keys included in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and DELETE) do not require checking to see if the key is coded; for those keys, you should simply use the key variable directly (and not keyCode). If you’re making cross-platform projects, note that the ENTER key is commonly used on PCs and Unix, while the RETURN key is used on Macs. Make sure your program will work on all platforms by checking for both ENTER and RETURN.

在ASCII规范包括键(Backspace,选项卡,输入,返回,ESC,和删除)不需要检查的关键是编码;这些键,你应该使用的关键变量(而不是密码)。如果您正在进行跨平台项目,请注意输入键通常用于个人计算机和UNIX,而返回密钥用于Mac。通过检查输入和返回,确保您的程序将在所有平台上工作。

For those familiar with Java, the values for UP and DOWN are simply shorter versions of Java’s KeyEvent.VK_UP and KeyEvent.VK_DOWN. Other keyCode values can be found in the Java KeyEvent reference.

对于那些熟悉java,为向上和向下的价值仅仅是短的keyevent.vk_up和keyevent.vk_down java版本。其他键位keyEvent值可以在java参考发现。

There are issues with how keyCode behaves across different renderers and operating systems. Watch out for unexpected behavior as you switch renderers and operating systems and you are using keys are aren’t mentioned in this reference entry.

有密码的行为如何在不同的渲染器和操作系统的问题。小心意外的行为,当你切换渲染器和操作系统,您使用的是钥匙不在参考词条中提到。

Related(相关函数):key
keyPressed
keyPressed()
keyReleased()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。