LoginSignup
2
0

More than 5 years have passed since last update.

Macで右Commandキーで入力言語をタイ語に切り替える

Last updated at Posted at 2018-06-16

毎回Command+Spaceで言語を選択するのがめんどくさかったのでHammerspoonを使って右⌘キーでタイ語入力になるように設定しました。

init.lua
ctrlPressed = false
keyPressed = false
layoutWatcher = hs.eventtap.new({hs.eventtap.event.types.flagsChanged, hs.eventtap.event.types.keyUp}, function(e)
    local flags = e:getFlags()
    local keyCode = e:getKeyCode()
    if flags.cmd and keyCode == 0x36 and not (flags.alt or flags.shift or flags.ctrl or flags.fn) then
        ctrlPressed = true
        keyPressed = false
    elseif ctrlPressed and not (flags.cmd or flags.alt or flags.shift or flags.ctrl or flags.fn) and not keyPressed then
        ctrlPressed = false
        if keyCode == 0x36 then
            hs.keycodes.setLayout("Thai")
        end
    else
        keyPressed = true
    end
end)

layoutWatcher:start()

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0