Created
April 8, 2019 14:08
-
-
Save kimitoboku/7660d9d5d78e3960a8ae4b2135781f68 to your computer and use it in GitHub Desktop.
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
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