Last active
February 28, 2021 10:55
-
-
Save c-l-nguyen/7e1bd3ef3c1e39087934e9f6fd23618d to your computer and use it in GitHub Desktop.
Hammerspoon virtual numpad for macOS
This file contains 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
Alright I think I got it figured out. Try this config. It will make ctrl-shift-n toggle virtual numpad. (Feel free to change that.)
Just install Hammerspoon, choose "File >Open Config", paste this in, save, then go back to Hammerspooon and choose "Reload Config”. On macOS Catalina, be sure to go into System Preferences > Security & Privacy > Privacy > Accessibility > Check "Hammerspoon.app"