1
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?

[Mac] sendkeys に『英数』『かな』キーを追加

Last updated at Posted at 2025-03-31

sendkeysとは、

任意のキーコードを送出できる、macOS向けのユーティリティコマンドです。
(最新はマウスコマンドの送出も可能)

しかし、日本語キーボードにある『英数』『かな』がありません。そこで、この2つのキーを追加します。

手順

上記GitHubからリポジトリをダウンロードして、数行追加します。

1. ソースコード改修

ダウンロードしたリポジトリのディレクトリを./sendkeys-mainと仮定。
環境により適宜読み替えてください。

sendkeys-main/Sources/SendKeysLib/KeyCodes.swift
//124行目付近
    static let keypad7: UInt16 = 0x59
    static let keypad8: UInt16 = 0x5B
    static let keypad9: UInt16 = 0x5C

+    // JP-Keyboard
+    static let eisuu: UInt16 = 0x66 //英数
+    static let kana: UInt16 = 0x68 //かな


//267行目付近
        "keypad7": KeyCodeWithFlags(keypad7),
        "keypad8": KeyCodeWithFlags(keypad8),
        "keypad9": KeyCodeWithFlags(keypad9),

+        // JP-Keyboard
+        "eisuu": KeyCodeWithFlags(eisuu), //英数
+        "kana": KeyCodeWithFlags(kana), //かな
        
    ]   

2. ビルド

ビルド&インストールします。

cd sendkeys-main
make build
sudo make install

3. 権限設定

初めてsendkeysを実行すると 次のダイアログが表示されるので、システム設定 を開いて ターミナル に権限を付与します。

scr1.png scr2.png

使用例

sendkeys --application-name "Finder" --characters "<c:eisuu>"

Sleep から復帰後に初めてタイプするときに、『日本語』モードのままとなっていて、「あれれ」となることが多々ありました。

そこで、SleepWatcherを使用して、Sleep から復帰時に上記コマンドにて英数モードに戻すことで、このイライラを解消しました。

USキーボード使用時も問題なく機能します。



以上

1
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
1
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?