mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 18:10:43 +01:00
73 lines
998 B
XML
73 lines
998 B
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>keyPressed()</name>
|
|
|
|
<category>Input/Output</category>
|
|
|
|
<subcategory>Keyboard</subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image>keyPressed_.jar</image>
|
|
<code>
|
|
// Click on the image to give it focus,
|
|
// and then press any key
|
|
|
|
int value = 0;
|
|
|
|
void loop() {
|
|
fill(value);
|
|
rect(25, 25, 50, 50);
|
|
}
|
|
|
|
void keyPressed()
|
|
{
|
|
if(value == 0) {
|
|
value = 255;
|
|
} else {
|
|
value = 0;
|
|
}
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
The <b>keyPressed()</b> function is called once every time a key is pressed. As a general rule, nothing should be draw within the <b>keyPressed()</b> block.
|
|
</description>
|
|
|
|
<syntax>
|
|
void keyPressed() {
|
|
<c>statements</c>
|
|
}
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label></label>
|
|
<description></description>
|
|
</parameter>
|
|
|
|
<returns>None</returns>
|
|
|
|
<related>
|
|
keyPressed
|
|
key
|
|
keyCode
|
|
keyReleased()
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Function</type>
|
|
|
|
<partof>Core</partof>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</root>
|