KeyRemap4MacBookはOS X用キーボードカスタマイザの決定版ですが、窓使いの憂鬱からの移民としてはとにかくいじりがいがあるので、手元でいろいろ設定を追加しています。その中でも汎用性が高いと思われるやつをひとつ紹介。
US配列で右Commandキーの右にある「Enter」は、なかなかいい場所にあるのに使用頻度の低いかわいそうな子。KeyRemap4MacBookでも様々なキーへのマッピングが用意されていますが、僕はOptionキーにしています。Optionはメタキーとして欧文文字の入力に使いますが、ギリシャ文字や学術記号等、大して必要のないものも多いので、デスクトップ操作等のグローバルショートカットに活用しています。
しかし、EnterをOptionにするだけではもったいない。日本語使いがキーボードを使っていて何がまどろっこしいって、入力モードの切り替えの面倒さ。OS XのCommand+Spaceはとてもいい組み合わせだけど、両の親指を使うのが気に食わない。そこで、Enter単独押しでモード切替できたらいいんじゃね?というパッチがこれ。(download)
diff -r f0c59438beaf files/prefpane/sysctl.xml
--- a/files/prefpane/sysctl.xml Thu Feb 21 11:23:13 2008 +0900
+++ b/files/prefpane/sysctl.xml Fri Feb 22 16:15:20 2008 +0900
@@ -83,6 +83,12 @@
<item>
<name>Enter to Option_L</name>
<sysctl>keyremap4macbook.remap.enter2optionL</sysctl>
+ <list>
+ <item>
+ <name>Non-modifier Enter to Command_L+Space</name>
+ <sysctl>keyremap4macbook.option.enter2optionL_commandspace</sysctl>
+ </item>
+ </list>
</item>
<item>
<name>Enter to Command_L+Control_L</name>
diff -r f0c59438beaf src/kext/config.cpp
--- a/src/kext/config.cpp Thu Feb 21 11:23:13 2008 +0900
+++ b/src/kext/config.cpp Fri Feb 22 16:15:20 2008 +0900
@@ -76,6 +76,9 @@ namespace org_pqrs_KeyRemap4MacBook {
SYSCTL_INT(_keyremap4macbook_remap, OID_AUTO, enter2optionL, CTLTYPE_INT|CTLFLAG_RW,
&(config.remap_enter2optionL), 0, "");
+ SYSCTL_INT(_keyremap4macbook_option, OID_AUTO, enter2optionL_commandspace, CTLTYPE_INT|CTLFLAG_RW,
+ &(config.option_enter2optionL_commandspace), 0, "");
+
SYSCTL_INT(_keyremap4macbook_remap, OID_AUTO, enter2commandLcontrolL, CTLTYPE_INT|CTLFLAG_RW,
&(config.remap_enter2commandLcontrolL), 0, "");
@@ -370,7 +373,10 @@ namespace org_pqrs_KeyRemap4MacBook {
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2commandL);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2controlL);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2fn);
+
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2optionL);
+ sysctl_register_oid(&sysctl__keyremap4macbook_option_enter2optionL_commandspace);
+
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2commandLcontrolL);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2commandLshiftL);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2semicolon);
@@ -515,7 +521,10 @@ namespace org_pqrs_KeyRemap4MacBook {
sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2commandL);
sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2controlL);
sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2fn);
+
sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2optionL);
+ sysctl_unregister_oid(&sysctl__keyremap4macbook_option_enter2optionL_commandspace);
+
sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2commandLcontrolL);
sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2commandLshiftL);
sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2semicolon);
diff -r f0c59438beaf src/kext/config.hpp
--- a/src/kext/config.hpp Thu Feb 21 11:23:13 2008 +0900
+++ b/src/kext/config.hpp Fri Feb 22 16:15:20 2008 +0900
@@ -31,7 +31,10 @@ namespace org_pqrs_KeyRemap4MacBook {
int remap_enter2commandL;
int remap_enter2controlL;
int remap_enter2fn;
+
int remap_enter2optionL;
+ int option_enter2optionL_commandspace;
+
int remap_enter2commandLcontrolL;
int remap_enter2commandLshiftL;
int remap_enter2semicolon;
diff -r f0c59438beaf src/kext/keycode.hpp
--- a/src/kext/keycode.hpp Thu Feb 21 11:23:13 2008 +0900
+++ b/src/kext/keycode.hpp Fri Feb 22 16:15:20 2008 +0900
@@ -156,6 +156,7 @@ namespace org_pqrs_KeyRemap4MacBook {
namespace CharCode {
enum {
CONTROL_L = 0,
+ COMMAND_L = 0,
FN = 0,
TAB = 9,
RETURN = 13,
diff -r f0c59438beaf src/kext/remap.cpp
--- a/src/kext/remap.cpp Thu Feb 21 11:23:13 2008 +0900
+++ b/src/kext/remap.cpp Fri Feb 22 16:15:20 2008 +0900
@@ -122,7 +122,35 @@ namespace org_pqrs_KeyRemap4MacBook {
{
if (! config.remap_enter2optionL) return;
- RemapUtil::keyToModifier(params, RemapUtil::getEnterKeyCode(params), ModifierFlag::OPTION_L);
+ KeyCode::KeyCode enterKeyCode = RemapUtil::getEnterKeyCode(params);
+
+ if (config.option_enter2optionL_commandspace) {
+ static bool useEnterAsOption = false;
+
+ if (params.ex_origKey != enterKeyCode && *(params.eventType) == KeyEvent::DOWN) {
+ useEnterAsOption = true;
+ }
+
+ if (params.ex_origKey == enterKeyCode) {
+ // Enter => OptionL (if type EnterKey only, works as EnterKey)
+ unsigned int origEventType = *(params.eventType);
+ RemapUtil::keyToModifier(params, enterKeyCode, ModifierFlag::OPTION_L);
+
+ if (origEventType == KeyEvent::DOWN) {
+ useEnterAsOption = false;
+
+ } else if (origEventType == KeyEvent::UP) {
+ if (useEnterAsOption == false) {
+ listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::MODIFY, ModifierFlag::COMMAND_L, KeyCode::COMMAND_L, CharCode::COMMAND_L);
+ listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::DOWN, ModifierFlag::COMMAND_L, KeyCode::SPACE, CharCode::SPACE);
+ listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::UP, ModifierFlag::COMMAND_L, KeyCode::SPACE, CharCode::SPACE);
+ listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::MODIFY, 0, KeyCode::COMMAND_L, CharCode::COMMAND_L);
+ }
+ }
+ }
+ } else {
+ RemapUtil::keyToModifier(params, enterKeyCode, ModifierFlag::OPTION_L);
+ }
}
void
親指でタン、と叩いて切り替えるのは昔からのお気に入りで、mayuではこうしていました。
mod alt -= RAlt
key *RAlt = $ToggleIME
mod alt += !!RAlt
Kinesis Contoured Keyboardでは、右CtrlをEnterにマッピングして、上記の設定で使っています。快適快適。