Last active
February 16, 2025 17:12
-
-
Save c-l-nguyen/7e1bd3ef3c1e39087934e9f6fd23618d to your computer and use it in GitHub Desktop.
Hammerspoon virtual numpad for macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k = hs.hotkey.modal.new('ctrl-shift', 'n') | |
function k:entered() hs.alert'Virtual Numpad' end | |
function k:exited() hs.alert'Exit Virtual Numpad' end | |
k:bind('ctrl-shift', 'n', function() k:exit() end) | |
hs.fnutils.each({ | |
{ key='j', padkey='pad1'}, | |
{ key='k', padkey='pad2'}, | |
{ key='l', padkey='pad3'}, | |
{ key='u', padkey='pad4'}, | |
{ key='i', padkey='pad5'}, | |
{ key='o', padkey='pad6'}, | |
{ key='7', padkey='pad7'}, | |
{ key='8', padkey='pad8'}, | |
{ key='9', padkey='pad9'}, | |
{ key='m', padkey='pad0'}, | |
{ key='/', padkey='pad+'}, | |
{ key=';', padkey='pad-'}, | |
{ key='p', padkey='pad*'}, | |
{ key='0', padkey='pad/'}, | |
}, function(vmap) | |
k:bind({}, vmap.key, | |
function() hs.eventtap.keyStroke({}, vmap.padkey, 20) end, | |
nil, | |
function() hs.eventtap.keyStroke({}, vmap.padkey, 20) end) | |
end | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have experience with mouse movements and clicks. So built-in mechanics are not working in this VM. The mouse moves, but the VM does not respond to that action, e.g. some hover action should be triggered and clicks did not work.
And I ended up with using shell CLI
cliclick
app and use it directly. Probably, HS has some common issue with emulating that does not in VMs.Code