Windows 10如何设置数字/特殊字符键默认输入替代字符?
实现永久特殊字符锁定(替代大写锁定)的方案
我刚好折腾过类似的需求,不用找新的键盘布局,用自定义脚本或者工具就能完美实现你要的效果——让数字键、减号、等号这些按键默认输出对应的上档特殊字符,同时覆盖.;这类键位。下面分不同系统给你具体方案:
Windows系统:用AutoHotkey实现
AutoHotkey是Windows上免费且强大的键盘自动化工具,写个简单脚本就能搞定:
- 先下载安装AutoHotkey(免费开源,直接搜官网就能找到)
- 新建一个文本文件,把下面的代码粘贴进去,然后把文件后缀改成
.ahk:
; 数字键映射:按下1输出!,2输出@,以此类推 1::SendInput ! 2::SendInput @ 3::SendInput # 4::SendInput $ 5::SendInput % 6::SendInput ^ 7::SendInput & 8::SendInput * 9::SendInput ( 0::SendInput ) ; 其他特殊键映射 -::SendInput _ =::SendInput + [::SendInput { ]::SendInput } ;::SendInput : '::SendInput " ,::SendInput < .::SendInput > /::SendInput ?
- 双击这个
.ahk文件就能生效,要是想开机自动运行,把它的快捷方式放到启动文件夹里(Win+R输入shell:startup,打开后粘贴快捷方式就行)
小技巧:如果临时需要输入原字符(比如想打个普通的1),按住Shift再按对应键就行,脚本会识别并输出原键位。
macOS系统:用Karabiner-Elements配置
macOS上推荐用Karabiner-Elements,这是专门用来自定义键盘的工具:
- 安装Karabiner-Elements(App Store或者官网都能下,免费)
- 打开软件后,进入「Complex Modifications」板块,点击「Add rule」,可以选择导入现成规则,也能自己写规则:
新建一个JSON文件,粘贴下面的内容,然后导入到Karabiner里:
{ "title": "Permanent Shift for Symbol Keys", "rules": [ { "description": "Map number keys to shifted symbols", "manipulators": [ {"type": "basic", "from": {"key_code": "1"}, "to": {"key_code": "1", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "2"}, "to": {"key_code": "2", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "3"}, "to": {"key_code": "3", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "4"}, "to": {"key_code": "4", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "5"}, "to": {"key_code": "5", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "6"}, "to": {"key_code": "6", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "7"}, "to": {"key_code": "7", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "8"}, "to": {"key_code": "8", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "9"}, "to": {"key_code": "9", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "0"}, "to": {"key_code": "0", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "hyphen"}, "to": {"key_code": "hyphen", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "equal_sign"}, "to": {"key_code": "equal_sign", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "open_bracket"}, "to": {"key_code": "open_bracket", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "close_bracket"}, "to": {"key_code": "close_bracket", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "semicolon"}, "to": {"key_code": "semicolon", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "quote"}, "to": {"key_code": "quote", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "comma"}, "to": {"key_code": "comma", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "period"}, "to": {"key_code": "period", "modifiers": ["shift"]}}, {"type": "basic", "from": {"key_code": "slash"}, "to": {"key_code": "slash", "modifiers": ["shift"]}} ] } ] }
- 启用这个规则后就生效了,同样,临时输入原字符按住Shift就行,也可以在Karabiner里设置一个切换快捷键(比如CapsLock)来随时开启/关闭这个映射。
Linux系统:用xmodmap修改键位
Linux下可以用原生的xmodmap工具来修改键位,不需要额外安装软件:
- 在家目录下新建一个
.Xmodmap文件,粘贴下面的内容:
! 数字键默认输出上档字符,按住Shift输出原数字 keycode 10 = exclam exclam 1 1 keycode 11 = at at 2 2 keycode 12 = numbersign numbersign 3 3 keycode 13 = dollar dollar 4 4 keycode 14 = percent percent 5 5 keycode 15 = asciicircum asciicircum 6 6 keycode 16 = ampersand ampersand 7 7 keycode 17 = asterisk asterisk 8 8 keycode 18 = parenleft parenleft 9 9 keycode 19 = parenright parenright 0 0 ! 其他特殊键映射 keycode 20 = underscore underscore minus minus keycode 21 = plus plus equal equal keycode 26 = braceleft braceleft bracketleft bracketleft keycode 27 = braceright braceright bracketright bracketright keycode 47 = colon colon semicolon semicolon keycode 48 = quotedbl quotedbl apostrophe apostrophe keycode 59 = less less comma comma keycode 60 = greater greater period period keycode 61 = question question slash slash
- 打开终端,输入
xmodmap ~/.Xmodmap命令就能立即生效 - 要让开机自动加载,把这个命令加到桌面环境的启动项里(比如GNOME的「启动应用程序」,或者把命令添加到
~/.bashrc里)
注意:如果你的键盘键码和上面的不一样,可以用xev命令查看具体键码,调整对应行的keycode数值就行。
内容的提问来源于stack exchange,提问作者Quinn
相关产品推荐
相关产品推荐

