Skip to content

Commit f0a1ce0

Browse files
skressthomashoneyman
authored andcommitted
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. (#50)
1 parent 467b35f commit f0a1ce0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Select.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ handleAction handleAction' handleEvent = case _ of
296296
Key ev -> do
297297
void $ H.fork $ handle $ SetVisibility On
298298
let preventIt = H.liftEffect $ preventDefault $ KE.toEvent ev
299-
case KE.code ev of
300-
"ArrowUp" ->
299+
case KE.key ev of
300+
x | x == "ArrowUp" || x == "Up" ->
301301
preventIt *> handle (Highlight Prev)
302-
"ArrowDown" ->
302+
x | x == "ArrowDown" || x == "Down" ->
303303
preventIt *> handle (Highlight Next)
304-
"Escape" -> do
304+
x | x == "Escape" || x == "Esc" -> do
305305
inputElement <- H.getHTMLElementRef $ H.RefLabel "select-input"
306306
preventIt
307307
for_ inputElement (H.liftEffect <<< HTMLElement.blur)

0 commit comments

Comments
 (0)