-
Notifications
You must be signed in to change notification settings - Fork 574
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
same KeyEvent from within hotkey.bind #2081
Comments
I'm not entirely sure I understand your question, but I think what you're after is better achieved with For example: hs.eventtap.new({hs.eventtap.event.types.keyUp}, function(event)
local flags = event:getFlags()
local keyCode = event:getKeyCode()
if flags:containExactly({"ctrl"}) and keyCode == hs.keycodes.map["c"] then
print("CTRL+C has been pressed.")
-- INSERT LOGIC HERE.
local shouldTheEventBeDeleted = true -- true if the event should be deleted, false if it should propagate to any other applications watching for that event
local tableOfEventsToPost = {} -- a table of events to post
return shouldTheEventBeDeleted, tableOfEventsToPost
end
end):start() |
If you're wanting the key combo to do something for most applications, but not for a few specific ones, you're better off using a window filter or application watcher and enabling/disabling the hotkey(s) when the active application changes. Hotkey's as defined with Watching for a hotkey with Search the issues and you should find some examples of watchers that should point you in the right direction... I'll try and post an example later but I'm not at my computer at the moment. |
As usual, @asmagill makes a really good point. Here's an example of how to use There's an example of using |
Thank you everyone for you help. Closing this, since not a real issue |
I was able to get this working by adapting some code from some dot files
I have no idea if this is a smart way to do it, but it was the only way I could get it to work. |
I need to bind a key and based on certain logic from within hs.hotkey.bind need to emulate the same sequence.
Let's say, for example I have a global bind:
Control-C
. Imagine in browser it would do something, but in Emacs it should do nothing, but also it should not shadow Emacs's default keybinding. So it needs to "throw the keys back" - replayControl-C
sequence.I've been trying to get this right using eventtap.event.newKeyEvent, hs.timer.doAfter - nothing works. Can someone help me to get this right? Thanks a lot!
The text was updated successfully, but these errors were encountered: