-
-
Save alogic0/ea93643d574077192a4375288d913421 to your computer and use it in GitHub Desktop.
Global keypress events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- source https://gist.github.com/ali-abrar/6cdf28d6fb9c3dbe25fb | |
import Control.Monad.IO.Class | |
import GHCJS.DOM (webViewGetDomDocument) | |
import GHCJS.DOM.Document (getBody) | |
import GHCJS.DOM.Element (keyDown) | |
import GHCJS.DOM.EventM (on, preventDefault) | |
import Reflex.Dom | |
main :: IO () | |
main = mainWidget $ do | |
wv <- askWebView | |
Just doc <- liftIO $ webViewGetDomDocument wv | |
Just body <- liftIO $ getBody doc | |
kp <- wrapDomEvent body (`on` keyDown) $ do | |
i <- getKeyEvent | |
preventDefault | |
return i | |
display =<< holdDyn Nothing (fmap Just kp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment