2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Karabiner の Use KANA as KANA/EISUU (toggle) を hammerspoon で

Posted at

init.lua

local KEY_CODE_JIS_EISUU = 102
local KEY_CODE_JIS_KANA  = 104

local function isInputSourceKana()
  -- 利用中の IME に合わせて要修正
  -- cf. hs.logger.new('IM', 'debug'):d(hs.inspect(hs.keycodes.methods()))
  return hs.keycodes.currentMethod() == 'ひらがな(ATOK)'
end

local toggleInputSource
toggleInputSource = hs.hotkey.bind({}, KEY_CODE_JIS_KANA, function()
  if isInputSourceKana() then
    return hs.eventtap.keyStroke({}, KEY_CODE_JIS_EISUU, 0)
  end

  toggleInputSource:disable()
  hs.eventtap.keyStroke({}, KEY_CODE_JIS_KANA, 0)
  toggleInputSource:enable()
end)

備考

  • hs.keycodes.setMethodIM をセットするとメニューバー上のアイコンは変わるものの、実際にキーを叩くと意図通りにはならなかったので、英数/かなキーをストロークさせる様に
2
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?