Static p5_sys::global::keyTyped [−][src]
pub static keyTyped: KeyTypedInternalType
Expand description
The keyTyped() function is called once every time a key is pressed, but action keys such as Backspace, Delete, Ctrl, Shift, and Alt are ignored. If you are trying to detect a keyCode for one of these keys, use the keyPressed() function instead. The most recent key typed will be stored in the key variable.
Because of how operating systems handle key repeats, holding down a key
will cause multiple calls to keyTyped() (and keyReleased() as well). The
rate of repeat is set by the operating system and how each computer is
configured.
Browsers may have different default behaviors attached to various key
events. To prevent any default behavior for this event, add "return false"
to the end of the method.
Examples
let value = 0; function draw() { fill(value); rect(25, 25, 50, 50); } function keyTyped() { if (key === 'a') { value = 255; } else if (key === 'b') { value = 0; } // uncomment to prevent any default behavior // return false; }