I was trying to do keyboard input in 0.19. I discovered 2 things:
(1) packages.elm told me to look at Browser.Events ( https://package.elm-lang.org/packages/elm/browser/latest/Browser-Events ). Browser.Events told me to look here: https://github.com/elm/browser/blob/1.0.0/examples/wasd.md , which doesn’t exist. So I instead looked at https://github.com/elm/browser/blob/master/examples/wasd.elm , which does exist, but doesn’t work with 0.19. After editing it a bit, it works, but poorly. Keep reading to find out why.
(2) Browser.Events tells me to read this: https://github.com/elm/browser/blob/1.0.0/notes/keyboard.md , which tells me that I should only ever use ‘key’ for the decoder function, and never ‘keyCode’, ‘code’, ‘charCode’, or ‘which’. This is a mistake. ‘key’ gives only the character produced by the key downed/pressed. If I want the key itself, no matter what character is produced according to the layout, I must use ‘code’. This distinction is very important to people that don’t use a qwerty keyboard (such as myself). (For what it’s worth, ‘keyCode’, ‘charCode’, and ‘which’ don’t seem to work at all.)
I’m not asking for advice about anything, I just thought I should share this useful information with the people using Elm, to counter the poor advice given by the Elm documentation, and the people creating Elm, so they can correct it.
Btw, this reminds me of something Firefox did: Starting in Firefox 3 (way back in 2008), Firefox destroyed the ability to use Firefox with a non-qwerty keyboard, because they tied shortcuts to the character produced by a key, instead of the key itself. ( https://bugzilla.mozilla.org/show_bug.cgi?format=default&id=439815 ) This bug (Although some people insisted it was a feature!) festered for the greater part of the past decade (it was not fixed in 2009 despite what bugzilla says) until they fixed it only recently (within the past year or two, iirc). Please don’t do as Firefox did.