Skip to content

Instantly share code, notes, and snippets.

@pchiusano
Created November 6, 2015 01:53
Show Gist options
  • Save pchiusano/25d53d29414d2f730b1d to your computer and use it in GitHub Desktop.
Save pchiusano/25d53d29414d2f730b1d to your computer and use it in GitHub Desktop.
Overriding the keyboard arrows in a Reflex text box
searchbox <- textInput def
let isArrow i = i == 38 || i == 40
let tweak e = e >>= \i -> if isArrow i then i <$ preventDefault else pure i
tweakedKeydown <- wrapDomEvent (_textInput_element searchbox) elementOnkeydown (tweak getKeyEvent)
_ <- widgetHold (pure ()) (fmap (const (pure ())) tweakedKeydown)
@oliver-batchelor
Copy link

performEvent_ (void tweakedKeydown)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment