Loading... 我有两把键盘,一把是普通的 108 键盘放家里,一把是 Poker II 放公司写代码用。Poker II 是一把可以硬件编程的键盘,我将 `Caps` 映射成了 `Fn` 然后就可以用 `Caps` + `WASD` 在不用移动手的情况下愉快地使用方向键了。然而在家用 108 键盘的时候不免习惯性地按到 `Caps`。于是萌生了用软映射的想法。 映射时顺手也把 hjkl 也映射成了方向键 ### 硬件解决 键位调整原理上就是要对输入的按键信号做一次转换罢了。于是有大佬做了个东西叫做[USB2USB_Converter](https://github.com/tmk/USB2USB_Converter "USB2USB_Converter")可以在硬件层面上做到映射。具体就不展开了。分享刷入固件时键位[代码](http://www.keyboard-layout-editor.com/#/gists/fee76f6e615e95df298a7ff0d60ae7db "代码") ``` ["Esc\n\n\n\nPower",{x:1},"F1","F2","F3","F4",{x:0.5},"F5","F6","F7","F8",{x:0.5},"F9","F10\n\n\n\nMute","F11\n\n\n\nVol_Dn","F12\n\n\n\nVol_Up",{x:0.25},"PrtSc","Scroll Lock","Pause\nBreak"], [{y:0.5},"~\n`","!\n1\n\n\nF1","@\n2\n\n\nF2","#\n3\n\n\nF3","$\n4\n\n\nF4","%\n5\n\n\nF5","^\n6\n\n\nF6","&\n7\n\n\nF7","*\n8\n\n\nF8","(\n9\n\n\nF9",")\n0\n\n\nF10","_\n-\n\n\nF11","+\n=\n\n\nF12",{w:2},"Backspace\n\n\n\nDelete",{x:0.25},"Insert","Home","PgUp",{x:0.25},"Num Lock","/","*","-"], [{w:1.5},"Tab","Q","W\n\n\n\n↑","E","R","T","Y","U\n\n\n\nPgDn","I\n\n\n\nPgUp","O","P","{\n[","}\n]",{w:1.5},"|\n\\",{x:0.25},"Delete","End","PgDn",{x:0.25},"7\nHome","8\n↑","9\nPgUp",{h:2},"+"], [{w:1.75},"Fn0","A\n\n\n\n←","S\n\n\n\n↓","D\n\n\n\n→","F","G","H\n\n\n\n←","J\n\n\n\n↓","K\n\n\n\n↑","L\n\n\n\n→",":\n;","\"\n'",{w:2.25},"Enter",{x:3.5},"4\n←","5","6\n→"], [{w:2.25},"Shift","Z","X","C","V","B","N","M","<\n,",">\n.","?\n/",{w:2.75},"RShift",{x:1.25},"↑",{x:1.25},"1\nEnd","2\n↓","3\nPgDn",{h:2},"PEnter"], [{w:1.25},"Ctrl",{w:1.25},"Win",{w:1.25},"Alt",{w:6.25},"Space",{w:1.25},"RAlt",{w:1.25},"RWin",{w:1.25},"Menu",{w:1.25},"RCtrl",{x:0.25},"←","↓","→",{x:0.25,w:2},"0\nIns",".\nDel"] ``` ### Linux 1. 安装 xcape xmodmap ```yay -S xcape xorg-xmodmap``` 2. 编辑或新建 ~/.Xmodmap 内容如下: ``` keycode 66 = Mode_switch keysym h = h H Left keysym l = l L Right keysym k = k K Up keysym j = j J Down keysym a = a A Left keysym d = d D Right keysym w = w W Up keysym s = s S Down ``` 执行```xmodmap ~/.Xmodmap```即可生效。 - 已知问题:jetbrains 家的 ide 中无效 ### Windows windows 下使用的是 AutoHotkey 实现的,还添加了,```Caps```+```U I```翻页。最后生成了 exe 设置为开机启动。 下载:[wasd_hkjl_ui.zip](https://blog.zhpjy.com/usr/uploads/2020/05/694479598.zip) 脚本如下 ``` ;关闭caps功能 SetCapsLockState, AlwaysOff ;左win+apsLock为caps LWin & CapsLock::CapsLock ;设置caps+hjkl为方向键 CapsLock & h:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Left} else if GetKeyState("Ctrl", "D") Send +^{Left} else Send +{Left} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Left} else Send ^{Left} else if GetKeyState("Alt", "D") Send !{Left} else Send {Left} return CapsLock & j:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Down} else if GetKeyState("Ctrl", "D") Send +^{Down} else Send +{Down} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Down} else Send ^{Down} else if GetKeyState("Alt", "D") Send !{Down} else Send {Down} return CapsLock & k:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Up} else if GetKeyState("Ctrl", "D") Send +^{Up} else Send +{Up} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Up} else Send ^{Up} else if GetKeyState("Alt", "D") Send !{Up} else Send {Up} return CapsLock & l:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Right} else if GetKeyState("Ctrl", "D") Send +^{Right} else Send +{Right} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Right} else Send ^{Right} else if GetKeyState("Alt", "D") Send !{Right} else Send {Right} return ;设置caps+ wasd 为方向键 CapsLock & w:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Up} else if GetKeyState("Ctrl", "D") Send +^{Up} else Send +{Up} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Up} else Send ^{Up} else if GetKeyState("Alt", "D") Send !{Up} else Send {Up} return CapsLock & a:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Left} else if GetKeyState("Ctrl", "D") Send +^{Left} else Send +{Left} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Left} else Send ^{Left} else if GetKeyState("Alt", "D") Send !{Left} else Send {Left} return CapsLock & s:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Down} else if GetKeyState("Ctrl", "D") Send +^{Down} else Send +{Down} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Down} else Send ^{Down} else if GetKeyState("Alt", "D") Send !{Down} else Send {Down} return CapsLock & d:: if GetKeyState("Shift", "D") if GetKeyState("Alt", "D") Send +!{Right} else if GetKeyState("Ctrl", "D") Send +^{Right} else Send +{Right} else if GetKeyState("Ctrl", "D") if (GetKeyState("Alt", "D")) Send !^{Right} else Send ^{Right} else if GetKeyState("Alt", "D") Send !{Right} else Send {Right} return ;caps+i 向上翻页 CapsLock & i:: send, {PgUp} ;caps+u 向下翻页 CapsLock & u:: send, {PgDn} return ``` > 参考: https://github.com/AlexP11223/hjkl-keybindings https://zhuanlan.zhihu.com/p/129268938 [1]: https://github.com/tmk/USB2USB_Converter "USB2USB_Converter" 最后修改:2021 年 03 月 14 日 12 : 32 AM © 允许规范转载 赞赏 如果觉得我的文章对你有用,请随意赞赏 ×Close 赞赏作者 扫一扫支付 支付宝支付 微信支付