-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to swallow all keys while the modal is up? #66
Comments
I've been thinking about how this could be tackled. Currently, it would require replacing some of the core functions in modal.fnl to change how modal bindings are handled. Today an idea came to mind linked above to create an advising system that makes it trivial to register functions that can be then replaced or modified by say filtering args, filtering return values, wrapping it, or replacing it directly. This provides an accessible means to achieve this functionality without pushing something like this on unexpected users. My current thoughts would be to using the proposed advising systems to override the modal bindings to also run the hs.eventtap system to handle keys. Anything that doesn't match a binding in the current menu will be ignored until an action is pressed or ESC. |
@futuro Unfortunately, It cannot be done easily, see: Hammerspoon/hammerspoon#1505. We had an open issue here long time ago see #1, and we decided to close it. Until Hammerspoon gets native support for this, I think it's not even worth tackling. |
That is the solution I had in mind. With the previous version of Spacehammer that would be a nightmare since the bindings were defined at runtime through code that was locally scoped to the modal API. Now they're defined statically in our config.fnl file making the more difficult part of knowing what is and is not a valid key significantly simpler than it was before. It may not be easy but I'm down for trying it, I had prototyped something like that for a more modal vim mode. (fn log-key
[event]
(let [key-code (: event :getKeyCode)
flags (: event :getFlags)
key-char (. hs.keycodes.map key-code)]
(values false {})))
(let [types hs.eventtap.event.types
tap (hs.eventtap.new [types.keyDown]
log-key)]
(: tap :start)) |
I don't know if I understand lua/fennel/hammerspoon well enough to be much help in building this, but please let me know if I can help test! |
With advice being merged that gives me a flexible entrypoint to explore this without introducing a controversial change. Will give this a shot in the next week or two. |
Hi!
Thanks for making spacehammer!
I've been wondering if there's a way to eat all keys while the modal is up (after I press the LEADER key). Sometimes I press a non-mapped key, and that gets passed through to the window in focus instead of doing something in the modal; is it currently possible to make all pressed keys go to spacehammer?
Thank you!
Evan
The text was updated successfully, but these errors were encountered: