Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
local prevKeyCode
local leftCommand = 0x37
local rightCommand = 0x36
local eisuu = 0x66
local kana = 0x68
local alert_eikana
local function keyStroke(modifiers, character)
hs.eventtap.keyStroke(modifiers, character, 1000)
end
local function handleEvent(e)
local keyCode = e:getKeyCode()
local isCmdKeyUp = not(e:getFlags()['cmd']) and e:getType() == hs.eventtap.event.types.flagsChanged
if isCmdKeyUp and prevKeyCode == leftCommand then
keyStroke({}, eisuu)
hs.alert.closeSpecific(alert_eikana)
alert_eikana = hs.alert.show("ABC", 0.3)
elseif isCmdKeyUp and prevKeyCode == rightCommand then
keyStroke({}, kana)
hs.alert.closeSpecific(alert_eikana)
alert_eikana = hs.alert.show("Hiragana", {fillColor = {blue = 1, alpha = 0.75}}, 0.3)
end
prevKeyCode = keyCode
end
eventtap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged, hs.eventtap.event.types.keyDown, hs.eventtap.event.types.keyUp}, handleEvent)
eventtap:start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.