1
Fork 0

Switch to using KeyboardEvent.key instead of KeyboardEvent.code as KeyboardEvent.code always returns 'undefined' in MS Edge and IE 11. Also handle 'Up', 'Down', 'Esc' in addition to 'ArrowUp', 'ArrowDown', 'Escape' as IE 11 returns these values as the pressed keys. ()

This commit is contained in:
Sören Kress 2020-01-17 17:34:09 +01:00 committed by Thomas Honeyman
commit f0a1ce0b45

View file

@ -296,12 +296,12 @@ handleAction handleAction' handleEvent = case _ of
Key ev -> do
void $ H.fork $ handle $ SetVisibility On
let preventIt = H.liftEffect $ preventDefault $ KE.toEvent ev
case KE.code ev of
"ArrowUp" ->
case KE.key ev of
x | x == "ArrowUp" || x == "Up" ->
preventIt *> handle (Highlight Prev)
"ArrowDown" ->
x | x == "ArrowDown" || x == "Down" ->
preventIt *> handle (Highlight Next)
"Escape" -> do
x | x == "Escape" || x == "Esc" -> do
inputElement <- H.getHTMLElementRef $ H.RefLabel "select-input"
preventIt
for_ inputElement (H.liftEffect <<< HTMLElement.blur)