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



Change KeyPad 0 to Num 0
private.change_keypad0_to_num0
__KeyToKey__ KeyCode::KEYPAD_0, KeyCode::KEY_0


Change KeyPad 1 to Num 1
private.change_keypad1_to_num1
__KeyToKey__ KeyCode::KEYPAD_1, KeyCode::KEY_1


Change KeyPad 2 to Num 2
private.change_keypad2_to_num2
__KeyToKey__ KeyCode::KEYPAD_2, KeyCode::KEY_2


Change KeyPad 3 to Num 3
private.change_keypad3_to_num3
__KeyToKey__ KeyCode::KEYPAD_3, KeyCode::KEY_3


Change KeyPad 4 to Num 4
private.change_keypad4_to_num4
__KeyToKey__ KeyCode::KEYPAD_4, KeyCode::KEY_4


Change KeyPad 5 to Num 5
private.change_keypad5_to_num5
__KeyToKey__ KeyCode::KEYPAD_5, KeyCode::KEY_5


Change KeyPad 6 to Num 6
private.change_keypad6_to_num6
__KeyToKey__ KeyCode::KEYPAD_6, KeyCode::KEY_6


Change KeyPad 7 to Num 7
private.change_keypad7_to_num7
__KeyToKey__ KeyCode::KEYPAD_7, KeyCode::KEY_7


Change KeyPad 8 to Num 8
private.change_keypad8_to_num8
__KeyToKey__ KeyCode::KEYPAD_8, KeyCode::KEY_8


Change KeyPad 9 to Num 9
private.change_keypad9_to_num9
__KeyToKey__ KeyCode::KEYPAD_9, KeyCode::KEY_9


Change KeyPad / to /
private.change_keypadslash_to_shift_slash
__KeyToKey__ KeyCode::KEYPAD_SLASH, KeyCode::SLASH


Change KeyPad * to shift+8
private.change_keypadasterisk_to_shift_shift_8
__KeyToKey__ KeyCode::KEYPAD_MULTIPLY, KeyCode::KEY_8, ModifierFlag::SHIFT_L


Change KeyPad - to -
private.change_keypadminus_to_shift_minus
__KeyToKey__ KeyCode::KEYPAD_MINUS, KeyCode::MINUS


Change KeyPad + to shift+=
private.change_keypadplus_to_shift_plus
__KeyToKey__ KeyCode::KEYPAD_PLUS, KeyCode::EQUAL, ModifierFlag::SHIFT_L


Change KeyPad Enter to Return
private.change_keypad_enter_to_return
__KeyToKey__ KeyCode::ENTER, KeyCode::RETURN


Change KeyPad Dot to Dot
private.change_keypad_dot_to_dot
__KeyToKey__ KeyCode::KEYPAD_DOT, KeyCode::DOT

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

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

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