Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

About WASD controls and alternative layouts: apparently JS supports key codes.

[1] https://www.w3schools.com/jsref/event_key_keycode.asp [2] https://keycode.info/

Edit: Apparently it is deprecated:

[3] https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEve... [4] https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEve...

Also there doesn't seem to be a way to detect the user's preferred layout before pressing any keys, that would make printing the instructions hard.



The linked article [3] links to KeyboardEvent.code which is not deprecated and still supports physical layout


> Also there doesn't seem to be a way to detect the user's preferred layout before pressing any keys, that would make printing the instructions hard

I am using a programmable keyboard that I’ve set up with a Dvorak-based layout. Here: https://configure.ergodox-ez.com/layouts/ENb6/latest/0

Games defaulting to WASD are fine as long as they allow changing the keybindings in the game.

I prefer that games do not try to detect keyboard layout because they’d probably get it wrong anyway.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: