3

My current attempt at getting an event of global keypress (eg: user hits a keyboard shortcut, from anywhere in the UI, to trigger opening of modal dialog) is:

  prerender_ blank $ do
    -- ctx <- askJSM
    doc <- currentDocumentUnchecked
    win <- currentWindowUnchecked
    let clicked = traceEvent "hit" $ keydown Enter win
    widgetHold_ (text "Waiting") $
      ffor clicked $ \() -> do
        text "CLICKED"

However, this fails to typecheck

    • Could not deduce: DomEventType JSDOM.Types.Window 
'KeydownTag ~ Word arising from a use of ‘keydown’

Looking at the source, only Element EventResult d t has an instance, but not Window or Document.

What is the idiomatic way to achieve what I'm trying to do here, in reflex / ghcjs?

Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187

0 Answers0