This is a follow up question to this topic:
Creating custom keyboard controls [Elm]
I'm adding a feature that allows players to customize controls. But the way arrow keys represent themselves is really weird. I'll get to that in a bit. What I have looks like this:
ck2up : Input [KeyCode]
ck2up = input [toCode 'W']
ck2down : Input [KeyCode]
ck2down = input [toCode 'S']
ck2left : Input [KeyCode]
ck2left = input [toCode 'A']
ck2right : Input [KeyCode]
ck2right = input [toCode 'D']
They receive input from Keyboard.keysDown while I'm clicking a button. This works fine for normal Char input, but when I want to use symbols I get some weird things. I wanted to give one player arrow keys by default, but since it has to be customized, I cannot use Keyboard.arrows. Player one will have:
ck1up : Input [KeyCode]
ck1up = input [8593]
ck1down : Input [KeyCode]
ck1down = input [8595]
ck1left : Input [KeyCode]
ck1left = input [8592]
ck1right : Input [KeyCode]
ck1right = input [8594]
This is taken from http://character-code.com/arrows-html-codes.php. These are the html codes for the arrow keys. I show the current keys on my buttons and the arrows show up properly:
(button ck1up.handle kd (append "up: " (fromList [fromCode pkeys1.up])))
with pkeys1.up containing the keycode. However, ingame the arrow keys don't respond. This is to be expected since html is made for layout, but when I try to use the unicode, as described http://library.elm-lang.org/catalog/elm-lang-Elm/0.13/Char toCode and fromCode, the keys ingame still don't work and I get an error icon where I expected the arrow symbols on the buttons. This might be because the unicode is in hexadecimals.
But! I can use my newly gained feature to customize controls by holding down keys while pressing a button. This did make my arrow keys work, but it showed the following symbols instead:
up: &
down: (
left: %
right: '
This means that the same unicode that made my arrow keys functional, are displaying these random symbols. Isn't that weird? If anyone know where I can find the unicode values Elm uses, that'd be great. I want to set up the arrow keys as default if no keys are entered. Does anything exist to convert these unicode to html as well, for proper display?
In case it matters, I'm still using Elm version 13.
Update
So I figured out the KeyCodes 38, 40, 37 and 39 respectively correspond to the arrow characters (and the display symbols correspond to these same values, but in html).