I to remap the ` key so that when I hold it it behave the same way as holding the alt key. For instance holding ` and pressing tab should behave as alt+tab.
I tried this, but it doesn't work. What am I doing wrong?
hs.hotkey.bind({}, "`", function() hs.eventtap.keyStroke({"alt"},"") end)
Create an eventtap and hook into the keyDown
event. Determine the keycode for the backtick (50
for my keyboard layout) and post key events to simulate that the alt (option) key was pressed. Finally return true
to surpress the original key (`).
local events = hs.eventtap.event.types
keyboardTracker = hs.eventtap.new({ events.keyDown }, function (e)
local keyCode = e:getKeyCode()
if keyCode == 50 then
hs.eventtap.event.newKeyEvent(hs.keycodes.map.alt,true):post()
hs.eventtap.event.newKeyEvent(hs.keycodes.map.alt,true):post()
return true
end
end)
keyboardTracker:start()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With