Windows 修改键盘映射(附带Linux下Ubuntu的修改方法)

一、简述

       通过修改键盘映射关系可以改变按键的功能。如:

      1) A键损坏,使用B键代替。

      2) 将某个按键屏蔽(屏蔽之后,这个按键就会没有反应一样)

      3)交换某些按键的功能。(将某些按键换到自己习惯的位置)

      可以通过相关软件进行修改,也可以通过注册表进行修改。例子中使用注册表方式进行修改键盘映射。

二、通过相关软件进行修改

        类似的软件有:SharpKeys.exe     github:https://github.com/randyrants/sharpkeys

       官网:http://www.randyrants.com/

      

      网盘链接: https://pan.baidu.com/s/12RzrzZa_txDunzFhPLcV7w 提取码: fc25 

三、通过注册表进行修改 (请慎重修改!!!)

      由于在编辑代码时,特别是使用vi编辑器时会经常用到方向键。P而gUp上翻与PgDn下翻与方向键靠的很近,导致想按方向键时很容易按到了翻页键,加上个人在编辑文本时习惯使用Home键(回到行首),End(回到行尾),配合Shift键可以选中一行。所以有了将上翻键(PgUp)映射为Home键,将下翻键(PgDn)映射为End键的想法。

                                                          

       举例:将PgUp上翻 映射为 Home键,将PgDn下翻映射为 End键。

       修改键盘映射:将以下内容保存为xxx.reg ,然后双击并确认。win7-64bit 需重启电脑才会生效。

Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] 
    "Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,4F,E0,51,E0,47,E0,49,E0,00,00,00,00 

 说明:
效果:将PgUp上翻 映射为 Home键,将PgDn下翻映射为 End键。    

    

补充:1) 如果想要某个键失效,就将其映射为00 00。

            2)可以将按键功能交换,例子中只是将PgUp上翻 映射为 Home键,将PgDn下翻映射为 End键。并没有将 Home键 映射为PgUp上翻 ,将End键 映射为 PgDn下翻。因为个人很少使用上翻和下翻。

            3)还原操作:

打开注册表
找到[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
然后删除”Scancode Map”键值

  打开注册表:在开始-》搜索程序和文件-》输入regedit-》回车。或者到C:\Windows\System32目录下运行regedt32.exe

附:键值表 

键值表
Backspace00 0E
Caps Lock00 3A
DeleteE0 53
EndE0 4F
Enter00 1C
Escape00 01
HOMEE0 52
InsertE0 52
Left Alt00 38
Left Ctrl00 1D
Left Shift00 2A
Left WindowsE0 5B
Num Lock00 45
Page DownE0 51
Page UpE0 49
PowerE0 5E
PrtScE0 37
Right AltE0 38
Right CtrlE0 1D
Right Shift00 36
ight WindowsE0 5C
Scroll Lock00 46
SleepE0 5F
Space00 39
Tab00 0F
WakeE0 63
100 4F
200 50
300 51
400 4B
500 4C
600 4D
700 47
800 48
900 49
000 52
-00 4A
/*00 37
.00 53
/00 35
/+00 4E
EnterE0 1C
F100 3B
F200 3C
F300 3D
F400 3E
F500 3F
F600 40
F700 41
F800 42
F900 43
F1000 44
F1100 57
F1200 58
F1300 64
F1400 65
F1500 66
DownE0 50
LeftE0 4B
RightE0 4D
UpE0 48
CalculatorE0 21
E-MailE0 6C
Media SelectE0 6D
MessengerE0 11
My ComputerE0 6B
’ ”00 28
- _00 0C
, <00 33
. >00 34
/ ?00 35
; :00 27
[ {00 1A
\ |00 2B
] }00 1B
` ~00 29
= +00 0D
0 )00 0B
1 !00 02
2 @00 03
3 #00 04
4 $00 05
5 %00 06
6 ^00 07
7 &00 08
8 *00 09
9 (00 0A
A00 1E
B00 30
C00 2E
D00 20
E00 12
F00 21
G00 22
H00 23
I00 17
J00 24
K00 25
L00 26
M00 32
N00 31
O00 18
P00 19 
Q00 10
R00 13
S00 1F
T00 14
U00 16
V00 2F
W00 11
XX 00 2D
Y00 15
Z00 2C
CloseE0 40
FwdE0 42
HelpE0 3B
NewE0 3E
Office HomeE0 3C
OpenE0 3F
PrintE0 58
RedoE0 07
ReplyE0 41
SaveE0 57
SendE0 43
SpellE0 23
Task PaneE0 3D
UndoE0 08
MuteE0 20
Next TrackE0 19
Play/PauseE0 22
Prev TrackE0 10
StopE0 24
Volume DownE0 2E
Volume UpE0 30
? -00 7D
Next to EnterE0 2B
Next to L-ShiftE0 56 
Next to R-ShiftE0 73
DBE_KATAKANAE0 70
DBE_SBCSCHARE0 77
CONVERTE0 79
NONCONVERTE0 7B
InternetE0 01
iTouchE0 13 
ShoppingE0 04 
WebcamE0 12
BackE0 6A
FavoritesE0 66
ForwardE0 69
HOMEE0 32
RefreshE0 67
SearchE0 65 
StopE0 68
My PicturesE0 64 
My MusicE0 3C 
MuteE0 20 
Play/PauseE0 22
StopE0 24
+ (Volume up)E0 30
- (Volume down)E0 2E
MediaE0 6D
MailE0 6C
Web/HomeE0 32
MessengerE0 05 
CalculatorE0 21
Log OffE0 16
SleepE0 5F 
Help(on F1 key)E0 3B
Undo(on F2 key)E0 08
Redo(on F3 key)E0 07
Fwd (on F8 key)E0 42
Send(on F9 key)E0 43

四、Linux下的修改键盘映射方法

       

      例子测试环境为在Ubuntu12.04和Ubuntu18.04。

       由于ESC按键损坏,而vi编辑器经常用到ESC按键,,因此将F1按键映射为ESC。(F1我比较少用,并且相邻ESC按键)

      在终端输入命令:xmodmap -pk  或xmodmap -pke 查看按键的code值

找到相应的键值,然后进行设置

因为系统重新启动之后,设置会失效,所以可以写为shell脚本方式,用到的时候直接执行脚本。 

#/bin/bash
#
xmodmap -e 'keysym F1 = Escape'

或者是

#/bin/bash
#
xmodmap -e 'keycode 67 = Escape'

 

(关机再启动 映射失效,想要生效就要在开机的时候手动的执行脚本一次,当然可以设置为启动脚本,就是让脚本在系统启动后自动执行)。

补充:1) 交换两个按键的功能(第二次运行就会换回原来的值)  尚未测试!!!

       交换 Caps_Lock and Control_L

       remove Lock = Caps_Lock
       remove Control = Control_L
       keysym Control_L = Caps_Lock
       keysym Caps_Lock = Control_L
       add Lock = Caps_Lock
       add Control = Control_L

                   

2) 开机执行脚本:

         a. 把脚本放置到启动目录下:sudo mv xxx.sh /etc/init.d/

         b. 将脚本添加到启动脚本:

          cd /etc/init.d/

          sudo update-rc.d xxx.sh defaults 90 #90表明一个优先级,越高表示执行的越晚

 

         移除Ubuntu开机脚本:sudo update-rc.d -f xxx.sh remove

附:键值表

liang@ubuntu:~$ xmodmap -pke
keycode   8 =
keycode   9 = Escape NoSymbol Escape
keycode  10 = 1 exclam 1 exclam
keycode  11 = 2 at 2 at
keycode  12 = 3 numbersign 3 numbersign
keycode  13 = 4 dollar 4 dollar
keycode  14 = 5 percent 5 percent
keycode  15 = 6 asciicircum 6 asciicircum
keycode  16 = 7 ampersand 7 ampersand
keycode  17 = 8 asterisk 8 asterisk
keycode  18 = 9 parenleft 9 parenleft
keycode  19 = 0 parenright 0 parenright
keycode  20 = minus underscore minus underscore
keycode  21 = equal plus equal plus
keycode  22 = BackSpace BackSpace BackSpace BackSpace
keycode  23 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode  24 = q Q q Q
keycode  25 = w W w W
keycode  26 = e E e E
keycode  27 = r R r R
keycode  28 = t T t T
keycode  29 = y Y y Y
keycode  30 = u U u U
keycode  31 = i I i I
keycode  32 = o O o O
keycode  33 = p P p P
keycode  34 = bracketleft braceleft bracketleft braceleft
keycode  35 = bracketright braceright bracketright braceright
keycode  36 = Return NoSymbol Return
keycode  37 = Control_L NoSymbol Control_L
keycode  38 = a A a A
keycode  39 = s S s S
keycode  40 = d D d D
keycode  41 = f F f F
keycode  42 = g G g G
keycode  43 = h H h H
keycode  44 = j J j J
keycode  45 = k K k K
keycode  46 = l L l L
keycode  47 = semicolon colon semicolon colon
keycode  48 = apostrophe quotedbl apostrophe quotedbl
keycode  49 = grave asciitilde grave asciitilde
keycode  50 = Shift_L NoSymbol Shift_L
keycode  51 = backslash bar backslash bar
keycode  52 = z Z z Z
keycode  53 = x X x X
keycode  54 = c C c C
keycode  55 = v V v V
keycode  56 = b B b B
keycode  57 = n N n N
keycode  58 = m M m M
keycode  59 = comma less comma less
keycode  60 = period greater period greater
keycode  61 = slash question slash question
keycode  62 = Shift_R NoSymbol Shift_R
keycode  63 = KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply XF86ClearGrab
keycode  64 = Alt_L Meta_L Alt_L Meta_L
keycode  65 = space NoSymbol space
keycode  66 = Caps_Lock NoSymbol Caps_Lock
keycode  67 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1
keycode  68 = F2 F2 F2 F2 F2 F2 XF86Switch_VT_2
keycode  69 = F3 F3 F3 F3 F3 F3 XF86Switch_VT_3
keycode  70 = F4 F4 F4 F4 F4 F4 XF86Switch_VT_4
keycode  71 = F5 F5 F5 F5 F5 F5 XF86Switch_VT_5
keycode  72 = F6 F6 F6 F6 F6 F6 XF86Switch_VT_6
keycode  73 = F7 F7 F7 F7 F7 F7 XF86Switch_VT_7
keycode  74 = F8 F8 F8 F8 F8 F8 XF86Switch_VT_8
keycode  75 = F9 F9 F9 F9 F9 F9 XF86Switch_VT_9
keycode  76 = F10 F10 F10 F10 F10 F10 XF86Switch_VT_10
keycode  77 = Num_Lock NoSymbol Num_Lock
keycode  78 = Scroll_Lock NoSymbol Scroll_Lock
keycode  79 = KP_Home KP_7 KP_Home KP_7
keycode  80 = KP_Up KP_8 KP_Up KP_8
keycode  81 = KP_Prior KP_9 KP_Prior KP_9
keycode  82 = KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract XF86Prev_VMode
keycode  83 = KP_Left KP_4 KP_Left KP_4
keycode  84 = KP_Begin KP_5 KP_Begin KP_5
keycode  85 = KP_Right KP_6 KP_Right KP_6
keycode  86 = KP_Add KP_Add KP_Add KP_Add KP_Add KP_Add XF86Next_VMode
keycode  87 = KP_End KP_1 KP_End KP_1
keycode  88 = KP_Down KP_2 KP_Down KP_2
keycode  89 = KP_Next KP_3 KP_Next KP_3
keycode  90 = KP_Insert KP_0 KP_Insert KP_0
keycode  91 = KP_Delete KP_Decimal KP_Delete KP_Decimal
keycode  92 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift
keycode  93 =
keycode  94 = less greater less greater bar brokenbar bar
keycode  95 = F11 F11 F11 F11 F11 F11 XF86Switch_VT_11
keycode  96 = F12 F12 F12 F12 F12 F12 XF86Switch_VT_12
keycode  97 =
keycode  98 = Katakana NoSymbol Katakana
keycode  99 = Hiragana NoSymbol Hiragana
keycode 100 = Henkan_Mode NoSymbol Henkan_Mode
keycode 101 = Hiragana_Katakana NoSymbol Hiragana_Katakana
keycode 102 = Muhenkan NoSymbol Muhenkan
keycode 103 =
keycode 104 = KP_Enter NoSymbol KP_Enter
keycode 105 = Control_R NoSymbol Control_R
keycode 106 = KP_Divide KP_Divide KP_Divide KP_Divide KP_Divide KP_Divide XF86Ungrab
keycode 107 = Print Sys_Req Print Sys_Req
keycode 108 = Alt_R Meta_R Alt_R Meta_R
keycode 109 = Linefeed NoSymbol Linefeed
keycode 110 = Home NoSymbol Home
keycode 111 = Up NoSymbol Up
keycode 112 = Prior NoSymbol Prior
keycode 113 = Left NoSymbol Left
keycode 114 = Right NoSymbol Right
keycode 115 = End NoSymbol End
keycode 116 = Down NoSymbol Down
keycode 117 = Next NoSymbol Next
keycode 118 = Insert NoSymbol Insert
keycode 119 = Delete NoSymbol Delete
keycode 120 =
keycode 121 = XF86AudioMute NoSymbol XF86AudioMute
keycode 122 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
keycode 123 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
keycode 124 = XF86PowerOff NoSymbol XF86PowerOff
keycode 125 = KP_Equal NoSymbol KP_Equal
keycode 126 = plusminus NoSymbol plusminus
keycode 127 = Pause Break Pause Break
keycode 128 = XF86LaunchA NoSymbol XF86LaunchA
keycode 129 = KP_Decimal KP_Decimal KP_Decimal KP_Decimal
keycode 130 = Hangul NoSymbol Hangul
keycode 131 = Hangul_Hanja NoSymbol Hangul_Hanja
keycode 132 =
keycode 133 = Super_L NoSymbol Super_L
keycode 134 = Super_R NoSymbol Super_R
keycode 135 = Menu NoSymbol Menu
keycode 136 = Cancel NoSymbol Cancel
keycode 137 = Redo NoSymbol Redo
keycode 138 = SunProps NoSymbol SunProps
keycode 139 = Undo NoSymbol Undo
keycode 140 = SunFront NoSymbol SunFront
keycode 141 = XF86Copy NoSymbol XF86Copy
keycode 142 = XF86Open NoSymbol XF86Open
keycode 143 = XF86Paste NoSymbol XF86Paste
keycode 144 = Find NoSymbol Find
keycode 145 = XF86Cut NoSymbol XF86Cut
keycode 146 = Help NoSymbol Help
keycode 147 = XF86MenuKB NoSymbol XF86MenuKB
keycode 148 = XF86Calculator NoSymbol XF86Calculator
keycode 149 =
keycode 150 = XF86Sleep NoSymbol XF86Sleep
keycode 151 = XF86WakeUp NoSymbol XF86WakeUp
keycode 152 = XF86Explorer NoSymbol XF86Explorer
keycode 153 = XF86Send NoSymbol XF86Send
keycode 154 =
keycode 155 = XF86Xfer NoSymbol XF86Xfer
keycode 156 = XF86Launch1 NoSymbol XF86Launch1
keycode 157 = XF86Launch2 NoSymbol XF86Launch2
keycode 158 = XF86WWW NoSymbol XF86WWW
keycode 159 = XF86DOS NoSymbol XF86DOS
keycode 160 = XF86ScreenSaver NoSymbol XF86ScreenSaver
keycode 161 = XF86RotateWindows NoSymbol XF86RotateWindows
keycode 162 = XF86TaskPane NoSymbol XF86TaskPane
keycode 163 = XF86Mail NoSymbol XF86Mail
keycode 164 = XF86Favorites NoSymbol XF86Favorites
keycode 165 = XF86MyComputer NoSymbol XF86MyComputer
keycode 166 = XF86Back NoSymbol XF86Back
keycode 167 = XF86Forward NoSymbol XF86Forward
keycode 168 =
keycode 169 = XF86Eject NoSymbol XF86Eject
keycode 170 = XF86Eject XF86Eject XF86Eject XF86Eject
keycode 171 = XF86AudioNext NoSymbol XF86AudioNext
keycode 172 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 173 = XF86AudioPrev NoSymbol XF86AudioPrev
keycode 174 = XF86AudioStop XF86Eject XF86AudioStop XF86Eject
keycode 175 = XF86AudioRecord NoSymbol XF86AudioRecord
keycode 176 = XF86AudioRewind NoSymbol XF86AudioRewind
keycode 177 = XF86Phone NoSymbol XF86Phone
keycode 178 =
keycode 179 = XF86Tools NoSymbol XF86Tools
keycode 180 = XF86HomePage NoSymbol XF86HomePage
keycode 181 = XF86Reload NoSymbol XF86Reload
keycode 182 = XF86Close NoSymbol XF86Close
keycode 183 =
keycode 184 =
keycode 185 = XF86ScrollUp NoSymbol XF86ScrollUp
keycode 186 = XF86ScrollDown NoSymbol XF86ScrollDown
keycode 187 = parenleft NoSymbol parenleft
keycode 188 = parenright NoSymbol parenright
keycode 189 = XF86New NoSymbol XF86New
keycode 190 = Redo NoSymbol Redo
keycode 191 = XF86Tools NoSymbol XF86Tools
keycode 192 = XF86Launch5 NoSymbol XF86Launch5
keycode 193 = XF86Launch6 NoSymbol XF86Launch6
keycode 194 = XF86Launch7 NoSymbol XF86Launch7
keycode 195 = XF86Launch8 NoSymbol XF86Launch8
keycode 196 = XF86Launch9 NoSymbol XF86Launch9
keycode 197 =
keycode 198 = XF86AudioMicMute NoSymbol XF86AudioMicMute
keycode 199 = XF86TouchpadToggle NoSymbol XF86TouchpadToggle
keycode 200 = XF86TouchpadOn NoSymbol XF86TouchpadOn
keycode 201 = XF86TouchpadOff NoSymbol XF86TouchpadOff
keycode 202 =
keycode 203 = Mode_switch NoSymbol Mode_switch
keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
keycode 205 = NoSymbol Meta_L NoSymbol Meta_L
keycode 206 = NoSymbol Super_L NoSymbol Super_L
keycode 207 = NoSymbol Hyper_L NoSymbol Hyper_L
keycode 208 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 209 = XF86AudioPause NoSymbol XF86AudioPause
keycode 210 = XF86Launch3 NoSymbol XF86Launch3
keycode 211 = XF86Launch4 NoSymbol XF86Launch4
keycode 212 = XF86LaunchB NoSymbol XF86LaunchB
keycode 213 = XF86Suspend NoSymbol XF86Suspend
keycode 214 = XF86Close NoSymbol XF86Close
keycode 215 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 216 = XF86AudioForward NoSymbol XF86AudioForward
keycode 217 =
keycode 218 = Print NoSymbol Print
keycode 219 =
keycode 220 = XF86WebCam NoSymbol XF86WebCam
keycode 221 =
keycode 222 =
keycode 223 = XF86Mail NoSymbol XF86Mail
keycode 224 = XF86Messenger NoSymbol XF86Messenger
keycode 225 = XF86Search NoSymbol XF86Search
keycode 226 = XF86Go NoSymbol XF86Go
keycode 227 = XF86Finance NoSymbol XF86Finance
keycode 228 = XF86Game NoSymbol XF86Game
keycode 229 = XF86Shop NoSymbol XF86Shop
keycode 230 =
keycode 231 = Cancel NoSymbol Cancel
keycode 232 = XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown
keycode 233 = XF86MonBrightnessUp NoSymbol XF86MonBrightnessUp
keycode 234 = XF86AudioMedia NoSymbol XF86AudioMedia
keycode 235 = XF86Display NoSymbol XF86Display
keycode 236 = XF86KbdLightOnOff NoSymbol XF86KbdLightOnOff
keycode 237 = XF86KbdBrightnessDown NoSymbol XF86KbdBrightnessDown
keycode 238 = XF86KbdBrightnessUp NoSymbol XF86KbdBrightnessUp
keycode 239 = XF86Send NoSymbol XF86Send
keycode 240 = XF86Reply NoSymbol XF86Reply
keycode 241 = XF86MailForward NoSymbol XF86MailForward
keycode 242 = XF86Save NoSymbol XF86Save
keycode 243 = XF86Documents NoSymbol XF86Documents
keycode 244 = XF86Battery NoSymbol XF86Battery
keycode 245 = XF86Bluetooth NoSymbol XF86Bluetooth
keycode 246 = XF86WLAN NoSymbol XF86WLAN
keycode 247 =
keycode 248 =
keycode 249 =
keycode 250 =
keycode 251 =
keycode 252 =
keycode 253 =
keycode 254 =
keycode 255 =

 

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐