Enum
KeyCode
View sourceDefines the numeric engine codes for keyboard keys.
Use these values with Keyboard and its inherited
Buttons queries. The keyboard plugin maps recognized browser code
strings to this set and uses KeyCode.Unidentified for an
unrecognized key. The values are engine-defined numbers rather than the
browser code strings themselves.
The set groups into letter keys (KeyCode.KeyA through
KeyCode.KeyZ), top-row digits (KeyCode.Digit1 through
KeyCode.Digit0), function keys (KeyCode.F1 through
KeyCode.F12), modifiers and navigation keys, numpad keys, and
common editing or punctuation keys such as
KeyCode.BackTick, KeyCode.Space, and
KeyCode.BackSpace.
Examples
import { Keyboard, KeyCode } from '@wimaengine/keyboard'
function handleInput(world) {
const keyboard = world.getResource(Keyboard)
if (keyboard.justPressed(KeyCode.Space)) {
console.log('jump')
}
}