koekeishiya / skhd

Simple hotkey daemon for macOS
MIT License
6.32k stars 210 forks source link

"noremap"-like functionality? #209

Open aydoo opened 2 years ago

aydoo commented 2 years ago
cmd - w : yabai -m window --toggle split

ctrl - w [
    "firefox" : skhd -k "cmd - w"
]

I would expect that in firefox, pressing ctrl - w would send a cmd - w action, i.e. to close the current tab. However, what actually happens is that yabai -m window --toggle split gets executed.

Question: Is there a way to avoid this kind of recursive remapping? Kind of like noremap keyword in vim?

es183923 commented 2 years ago

You could set the shortcut with macos natively, by going to System Preferences->Keyboard->Shortcuts->App Shortcuts and adding the shortcut

aydoo commented 2 years ago

You could set the shortcut with macos natively, by going to System Preferences->Keyboard->Shortcuts->App Shortcuts and adding the shortcut

Thanks for the suggestion, but unfortunately this is not possible for every shortcut, specifically those that do not have a menu bar entry such as cmd - l to focus the address bar.

dnz-bdeboer commented 2 years ago

Need a similar functionality. I have cmd + 1, cmd + 2, etc mapped to go to a desktop. I want alt + 1 to go to the first tab in Chrome. Chrome however only handles cmd + 1, and you cannot remap that in Chrome. So when I remap alt + 1 to cmd + 1 you actually switch the desktop, as skhd evaluates the keystroke from the beginning. I just want to stop evaluation, i.e. the noremap option.

jackielii commented 2 years ago

similar thing I did: map ctrl-1 through 9 to cmd-1 to 9 when cmd-1 is already mapped. My solution described here:

https://github.com/koekeishiya/skhd/issues/204#issuecomment-1137446716

bit verbose, and if you hit it too fast, it still sends the original mapping, but mostly work

berenddeboer commented 2 years ago

Hi @jackielii, I had looked at your solution, and whatever I tried, it didn't work for me. Your response made me have another go, and working perfectly now. Thank you so much!!

DoctorKnowsBetter commented 1 year ago

yup, very needed functionality