This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-21
Channels
- # announcements (11)
- # architecture (8)
- # aws (7)
- # babashka (1)
- # beginners (55)
- # calva (52)
- # cider (4)
- # clj-kondo (5)
- # clojure (12)
- # clojure-europe (7)
- # clojure-uk (3)
- # clojurescript (40)
- # clr (1)
- # conjure (5)
- # data-oriented-programming (7)
- # datomic (8)
- # emacs (3)
- # events (1)
- # graphql (2)
- # honeysql (5)
- # lsp (7)
- # missionary (24)
- # nbb (10)
- # off-topic (12)
- # pathom (5)
- # reagent (9)
- # reitit (4)
- # schema (1)
- # sci (9)
- # shadow-cljs (2)
- # specter (6)
- # tools-deps (4)
- # xtdb (13)
Is there a way to implement global keyboard controls in a reagent SPA? E.g. focusing a specific input on pressing A
while not having changed focus after loading the page and then being able to write in it.
Assuming I understand you correctly, you can do it via (.addEventListener document "keypress" ...)
.
You did yes. Thank you very much. Just need to figure out how to stop it from typing the shortcut into the input field now.
For that, in the event listener find the currently focused element. If that's an element that supports keyboard input, just propagate the event further (i.e. don't call .preventDefault
and .stopPropagation
).
Is there a good catch-all for keyboard input support or do I need to check the tag names and contentEditable separately?
I'd doing the latter myself. :) Couldn't find a any catch-all. But also makes sense given that any other component can also listen to keyboard events - it's up to you to figure out what you want to be done in each particular case.