Keyboard uses scancodes by default, which are based on physical key
positions rather than the logical (letter) meaning of the key.
When to use Keyboard
Using keyboard directly is discouraged, but of course allowed.
Take a look at the actions system in input for a better solution.
Also where there's text input such as enter your name, use the key code.
This allows the user to use their intended keyboard layout.
like.keypressed = (_code, key) => { name += key; }
Even if your game is heavily keyboard-reliant (like nethack), it is best to avoid mapping directly.
Referring to action drink instead of code KeyD is also more programmer-ergonomic.
A basic wrapper around keyboard.
Keyboard uses scancodes by default, which are based on physical key positions rather than the logical (letter) meaning of the key.
When to use Keyboard
Using keyboard directly is discouraged, but of course allowed. Take a look at the actions system in input for a better solution.
Also where there's text input such as
enter your name, use the key code. This allows the user to use their intended keyboard layout.Even if your game is heavily keyboard-reliant (like nethack), it is best to avoid mapping directly. Referring to action
drinkinstead of codeKeyDis also more programmer-ergonomic.