Up, Down, Left and Right keys do not repeat properly [Sierra, 0.9.52]
#1308 opened on Apr 5, 2017
Description
Related issues Earlier issue: #1156 Possibly related #1179, #1178
Client MacOS version: 10.12.3 Mac: MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)
Software hammerspoon 0.9.52
Description of issue In #1156 I mistakenly thought the repeat key randomly stopping was for all keys, I am certain now that it is only for Up, Down, Left and Right[direction keys] keys. At the very least, I am unable to reproduce it with any other key.
Use any of the methods below to test on Sierra and 0.9.52, try any key that is not a direction key, and it will repeat without issue.
Try to repeat on a direction key, and it will randomly stop after a seemingly random number of iterations.
One observable effect is that the random stop takes more repetitions to occur when you reload the hammerspoon config, but does still occur pretty much all the time.
.hammerspoon config
h = hs.hotkey.bind({}, "å", function()
hs.eventtap.event.newKeyEvent({}, "up", true):post()
end, function()
hs.eventtap.event.newKeyEvent({}, "up", false):post()
end, function()
hs.eventtap.event.newKeyEvent({}, "up", true):setProperty(hs.eventtap.event.properties.keyboardEventAutorepeat, 1):post()
end)
local function keyCode(key, modifiers)
modifiers = modifiers or {}
return function()
-- Keydown event only firing due to sleep and keyup
local event = require("hs.eventtap").event
event.newKeyEvent(modifiers, key, true):post()
hs.timer.usleep(100)
event.newKeyEvent(modifiers, string.lower(key), false):post()
end
end
hs.hotkey.bind({''}, 'å', keyCode('up'), nil, keyCode('up'))