Skip to content
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

backspace key code? #3642

Open
halafi opened this issue Jun 1, 2024 · 1 comment
Open

backspace key code? #3642

halafi opened this issue Jun 1, 2024 · 1 comment

Comments

@halafi
Copy link

halafi commented Jun 1, 2024

a bit new to hammerspoon, I am looking for backspace key code

keycodes.lua
am I missing something, I get this error:

Invalid key: backspace - this may mean that the key requested does not exist in your keymap (particularly if you switch keyboard layouts frequently)

more likely that backspace is registered as 51 but with hyper modifiers its not

Edit: after some more testing some keys don't get regstered with ctrl alt cmd shift pressed

@Rhys-T
Copy link

Rhys-T commented Jun 17, 2024

a bit new to hammerspoon, I am looking for backspace key code

Hammerspoon uses the Mac names for keys: delete is the key that deletes the previous character (what other systems call Backspace - this should be the one you need), while forwarddelete is the key that deletes the next character (what other systems call Delete).

print(hs.keycodes.map['delete']) -- 51
print(hs.keycodes.map['forwarddelete']) -- 117

Edit: after some more testing some keys don't get regstered with ctrl alt cmd shift pressed

Yeah, there are a few keyboard shortcuts with all four modifiers that are hardcoded into the system (mostly to trigger various diagnostic dumps from sysdiagnose), and can't be overridden by hs.hotkey. (See #616, #2557.) So far I've found mentions of Hyper-., Hyper-,, Hyper-/1, and Hyper-w2 doing this. Not sure if Hyper-Delete has anything like that or not.

If you need to take over one of those key combinations, your best bet is probably using something like Karabiner-Elements to remap e.g. Hyper-. to a completely different key, like F19 (example config here), before macOS ever sees it - then bind that key in Hammerspoon instead.

Alternately, you might be able to intercept that shortcut from Hammerspoon using an hs.eventtap instead of an hs.hotkey - but that has its own limitations, some of which are described in #2557 (comment). (It also won't work whenever you're using something that turns on Secure Input Mode, like a password field, or some terminal apps.)

Footnotes

  1. Mentioned on https://sayzlim.net/disable-sysdiagnose-key-combination/. Not sure what this one does.

  2. Mentioned on https://xam.io/2020/macos-diag-shortcuts/. Does Wifi diagnostics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants