Comment

Comment by jrockway

I suppose the problem is that sometimes you want keyboard shortcuts to be non-arbitrary keys. If you're on dvorak, you wouldn't want WASD to be your movement keys in an FPS. They are nowhere near each other. So applications need some sort of API to figure out what keyboard layout is in use, so they can setup the appropriate bindings. (The OS tells them which letter was pressed, not which (row, col) on the keyboard was pressed. But in this case, you kind of want that raw key matrix event.)

This is basically impossible, because the key matrix -> letter translation can be done in multiple places (in the keyboard firmware, in the OS, etc.). Hilariously, sometimes your keyboard firmware has to be aware of the OS translation; you cannot send a & keypress event over USB, so you have to send "shift + 7" if you want a key that generates that input. Because of all this, application developers have to add a "key binding preferences" page to their application. There is absolutely no way they can target a certain physical location on your keyboard.

None of this is specific to Javascript, of course. This is all about protocols and the OS.

parent jrockway 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton