Mac OS X中将失灵的小键盘映射成标准键盘(利用Karabiner)

用Mac OS X的时候,外接的键盘上面的小键盘(Key Pad)在一些程序上会失灵,比如iTerm2就会无法使用小键盘上面的数字回车加号减号星号斜杠。今天老蔡终于找到了一款可以解决这个问题的软件:Karabiner。

Karabiner是一款能帮Mac OS X改键的软件,键盘鼠标的键都可以改。

映射小键盘上面的星号、加号比较不同,需要把键位映射成组合键,其他的都是可以直接映射的。

至于如何导入配置,可以参考How to add your own settings

配置如下:

<?xml version="1.0"?>
<root>
<item>
<name>Change KeyPad 0 to Num 0</name>
<identifier>private.change_keypad0_to_num0</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_0, KeyCode::KEY_0</autogen>
</item>
<item>
<name>Change KeyPad 1 to Num 1</name>
<identifier>private.change_keypad1_to_num1</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_1, KeyCode::KEY_1</autogen>
</item>
<item>
<name>Change KeyPad 2 to Num 2</name>
<identifier>private.change_keypad2_to_num2</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_2, KeyCode::KEY_2</autogen>
</item>
<item>
<name>Change KeyPad 3 to Num 3</name>
<identifier>private.change_keypad3_to_num3</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_3, KeyCode::KEY_3</autogen>
</item>
<item>
<name>Change KeyPad 4 to Num 4</name>
<identifier>private.change_keypad4_to_num4</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_4, KeyCode::KEY_4</autogen>
</item>
<item>
<name>Change KeyPad 5 to Num 5</name>
<identifier>private.change_keypad5_to_num5</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_5, KeyCode::KEY_5</autogen>
</item>
<item>
<name>Change KeyPad 6 to Num 6</name>
<identifier>private.change_keypad6_to_num6</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_6, KeyCode::KEY_6</autogen>
</item>
<item>
<name>Change KeyPad 7 to Num 7</name>
<identifier>private.change_keypad7_to_num7</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_7, KeyCode::KEY_7</autogen>
</item>
<item>
<name>Change KeyPad 8 to Num 8</name>
<identifier>private.change_keypad8_to_num8</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_8, KeyCode::KEY_8</autogen>
</item>
<item>
<name>Change KeyPad 9 to Num 9</name>
<identifier>private.change_keypad9_to_num9</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_9, KeyCode::KEY_9</autogen>
</item>
<item>
<name>Change KeyPad / to /</name>
<identifier>private.change_keypadslash_to_shift_slash</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_SLASH, KeyCode::SLASH</autogen>
</item>
<item>
<name>Change KeyPad * to shift+8</name>
<identifier>private.change_keypadasterisk_to_shift_shift_8</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_MULTIPLY, KeyCode::KEY_8, ModifierFlag::SHIFT_L</autogen>
</item>
<item>
<name>Change KeyPad - to -</name>
<identifier>private.change_keypadminus_to_shift_minus</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_MINUS, KeyCode::MINUS</autogen>
</item>
<item>
<name>Change KeyPad + to shift+=</name>
<identifier>private.change_keypadplus_to_shift_plus</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_PLUS, KeyCode::EQUAL, ModifierFlag::SHIFT_L</autogen>
</item>
<item>
<name>Change KeyPad Enter to Return</name>
<identifier>private.change_keypad_enter_to_return</identifier>
<autogen>__KeyToKey__ KeyCode::ENTER, KeyCode::RETURN</autogen>
</item>
<item>
<name>Change KeyPad Dot to Dot</name>
<identifier>private.change_keypad_dot_to_dot</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_DOT, KeyCode::DOT</autogen>
</item>
</root>

 

本文是受到了oschina上的@yoyoso的一篇不完整的映射方案启发后探索和调试数个小时整理出来的。感谢@yoyoso同学。

使用发生错误之类的欢迎留言。

另外如果有兴趣,折腾完了键盘,可以继续折腾一下鼠标:Karabiner改鼠标上的快捷键