[关闭]
@torresdyl 2017-06-06T17:05:53.000000Z 字数 11187 阅读 16616

[MSKLC] How do I created my custom keyboard layout and remap ALL keys with MSKLC in Windows 10

未分类


0. Intruduction

Microsoft Keyboard Layout Creator is the best application in Windows platform to manipulate keyboard layout. It permits you to change your keyboard layout in a standard way which is fully compatible with Windows system (including Windows 10) at the level of VK code (i.e. Virtual Key code.). The most important is, even the application itself does not permit remapping modifer keys (Ctrl, Alt, etc.), with a little hack, we can change this behaviour and remap them too, and make UAC dialog aware of them even at system start up! That gives us complete control over your keyboard layout!

1. How to use MSKLC

Download MSKLC 1.4 in the link at the beginning. The developer of this application is Michael S. Kaplan. Cannot find much about this guy at Microsoft but I owe him a big thanks. It saves lots of days...
The required environment does not include Windows 10, but I find it working under Windows 10.

About how to use this software, you need a complete manual. Just explore and visit page to get some ideas:

http://www.angelfire.com/planet/linguisticsisfun/Creating_a_Keyboard_Using_MSKLC.pdf

You can learn by doing but at first, I must tell your some basic concepts in keyboard mapping.

2. Basic concepts and what MSKLC can do

Basically, MSKLC make it possible to:

Example of how to map dead key in MSKLC

For example, in my current keyboard layout, O is in the original position of P. If I don't change the VK code, when I press Ctrl+O, OS thinks I pressed Ctrl+P(because the combination it receives is Ctrl+VK_P), and prompts me the system print dialog. The same applies to other programs, among those I use daily, Microsoft Pinyin IME (input method). It used to let me go to next page/previous page with . and ,. Now, with my new keyboard layout, without VK code modification, when I press . and ,, the application does not receive VK_COMMA and VK_FULLSTOP events, so it stops to behave as expected.

As Microsoft states, all applications should only detect VK codes instead of the hardware-dependant "scan code" directly sent by key strokes. (By the way, I found that Google Pinyin does poorly at this aspect: it detects "key char" when I choose characters, and detects VK code when I navigate pages. Very bad UX. )

I provide some links to help you understand it better:

Receiving Keyboard Input (Windows CE 5.0)
Keyboard Input
Full VK code table 1
Full VK code table 2

"\" key has its VK code altered. Key at this position in a standard US keyboard originally has VK code VK_7.

Also, it makes it possible to remap modifiers, like Shift, Ctrl, Alt, Enter, Backspace and CapsLock. Originally I use AutoHotKey to swap Capslock with Left shift, and to swap Enter with Left shift. But one shortcoming of this approach is that these swapping is not visible to the OS under certain sensitive circumstances, like in Regestry editor, UAC confirm dialog, and login screen. And, I cannot make
AHK script functioning upon system startup, and it must be initialized manually. But, if we use MSKLC to remap them (with a hack which I will mention below), in all of these places OS recognise our remapping, and it does upon startup! An OS level hack, I must say.

3. My keyboard layout design: why it is like this and why

1. What it is like

The images are more persuasive.

Unshifted (no Shift, Alt, Ctrl pressed) state:

此处输入图片的描述

Shifted state: (pressing Shift)

此处输入图片的描述

AltGr state: (pressing AltGr, usually Right Alt, a helper key to get extra charaters)

此处输入图片的描述

AltGr state: (pressing AltGr and Shift, for capitalized letters)

此处输入图片的描述

Checking the images closely enough, you will find them familiar but different from the standard QWERTY keyboard layout. Yes, it is what I want to achieve: instead of changing the alphabetical keys' positions, doing a functional optimization for all the symbol keys to make programming easier. So I name it

QWERT^ Programmer layout with symbol keys optimized

2. Why my keyboard layout is like this

It has some important features:

1. It is programmer-friendly.

All paired symbols, like {}, [], (), <> and /\, are located symmetrically at the top number line, and meant to be pressed with the same finger of each hand. We all like symmetry because it is faster to remember: when you can press { with your little finger of your left hand, you expect to press the right half with your right hand, and most likely, also with little finger. So here you have it.

Also, the order of symbols are not arbitrary: in Chinese, we literally call {} "big parethesis", [] as "middle-sized parethesis", () is "parenthesis", and <> is "little parenthesis", so there is an order from the biggest to the smallest. In Java, the order still stands: {} are for methods and blocks, [] are for arrays, () for methods signatures and <> are for parameters. The scope of these symbols are ranked from the biggest to the smallest. So the biggest should be outside, and the smallest be inside.

As for / and \, imagine your both hand: try make your both hands' fingers meet, and they form a triangle, so / is for left hand and \ is for right hand. That's why / is on the left and \ is on the riht. Self-explantory, I would say. And, they are very common so I would like to type them with my strogest index finger.

Now, note that they are designed to be able to type without Shift, because for us programmer, these symbols are essential, and more frecuently typed than numbers. I use a full-sized 104 key keyboard, so if I don't want to press Shift to press number keys,I have numpad for numbers. Alternatively, in MSKLC I enable "CapsLock = Shift" for these number keys, so that I can press CapsLock and happily type numbers without numpad.

Another thing is that the numbers are also symmetrically located, and 6 to 0 are moved two columns to the right, so I can type numbers and paired symbols comfortably without looking at the keyboard, e.g. touch typing. Inspired by a post from here, I began to think about a easily missed point: in a most ergonomically natural position,
our hands stretch to both sides, not to the left
, so with numbers 0~9 sticking together and each hand handling 5 numbers, our right hand must extends itself to the left to cover its half, and it is wasted labor! But now, with 5 numbers on each side, I can spead my fingers to reach the keys symmetrically and naturally without moving my right hand, and it's faster to get to the right position.

  1. KBD WTVKMS "QWERT^ (VK code, Modifiers and Symmetrical numbers) - CN"
  2. COPYRIGHT "(c) 2017 WindThunder Studio"
  3. COMPANY "WindThunder Studio"
  4. LOCALENAME "zh-CN"
  5. LOCALEID "00000804"
  6. VERSION 1.0
  7. SHIFTSTATE
  8. 0 //Column 4
  9. 1 //Column 5 : Shft
  10. 2 //Column 6 : Ctrl
  11. 6 //Column 7 : Ctrl Alt
  12. 7 //Column 8 : Shft Ctrl Alt
  13. LAYOUT ;an extra '@' at the end is a dead key
  14. //SC VK_ Cap 0 1 2 6 7
  15. //-- ---- ---- ---- ---- ---- ---- ----
  16. 02 1 1 007b 1 -1 -1 -1 // LEFT CURLY BRACKET, DIGIT ONE, <none>, <none>, <none>
  17. 03 2 1 005b 2 -1 00b7 -1 // LEFT SQUARE BRACKET, DIGIT TWO, <none>, MIDDLE DOT, <none>
  18. 04 3 1 0028 3 -1 20ac -1 // LEFT PARENTHESIS, DIGIT THREE, <none>, EURO SIGN, <none>
  19. 05 4 1 003c 4 -1 -1 -1 // LESS-THAN SIGN, DIGIT FOUR, <none>, <none>, <none>
  20. 06 5 1 002f 5 -1 -1 -1 // SOLIDUS, DIGIT FIVE, <none>, <none>, <none>
  21. 07 OEM_MINUS 0 002d 005f -1 -1 -1 // HYPHEN-MINUS, LOW LINE, <none>, <none>, <none>
  22. 08 OEM_PLUS 0 003d 002b -1 00ac -1 // EQUALS SIGN, PLUS SIGN, <none>, NOT SIGN, <none>
  23. 09 6 1 005c 6 -1 -1 -1 // REVERSE SOLIDUS, DIGIT SIX, <none>, <none>, <none>
  24. 0a 7 1 003e 7 -1 -1 -1 // GREATER-THAN SIGN, DIGIT SEVEN, <none>, <none>, <none>
  25. 0b 8 1 0029 8 -1 -1 -1 // RIGHT PARENTHESIS, DIGIT EIGHT, <none>, <none>, <none>
  26. 0c 9 1 005d 9 -1 00a1 -1 // RIGHT SQUARE BRACKET, DIGIT NINE, <none>, INVERTED EXCLAMATION MARK, <none>
  27. 0d 0 1 007d 0 -1 00bf -1 // RIGHT CURLY BRACKET, DIGIT ZERO, <none>, INVERTED QUESTION MARK, <none>
  28. 10 Q 1 q Q -1 -1 -1 // LATIN SMALL LETTER Q, LATIN CAPITAL LETTER Q, <none>, <none>, <none>
  29. 11 W 1 w W -1 -1 -1 // LATIN SMALL LETTER W, LATIN CAPITAL LETTER W, <none>, <none>, <none>
  30. 12 E 1 e E -1 -1 -1 // LATIN SMALL LETTER E, LATIN CAPITAL LETTER E, <none>, <none>, <none>
  31. 13 R 1 r R -1 -1 -1 // LATIN SMALL LETTER R, LATIN CAPITAL LETTER R, <none>, <none>, <none>
  32. 14 T 1 t T -1 -1 -1 // LATIN SMALL LETTER T, LATIN CAPITAL LETTER T, <none>, <none>, <none>
  33. 15 OEM_6 0 0060 005e -1 00b4@ -1 // GRAVE ACCENT, CIRCUMFLEX ACCENT, <none>, ACUTE ACCENT, <none>
  34. 16 Y 1 y Y -1 -1 -1 // LATIN SMALL LETTER Y, LATIN CAPITAL LETTER Y, <none>, <none>, <none>
  35. 17 U 1 u U -1 -1 -1 // LATIN SMALL LETTER U, LATIN CAPITAL LETTER U, <none>, <none>, <none>
  36. 18 I 1 i I -1 -1 -1 // LATIN SMALL LETTER I, LATIN CAPITAL LETTER I, <none>, <none>, <none>
  37. 19 O 1 o O -1 -1 -1 // LATIN SMALL LETTER O, LATIN CAPITAL LETTER O, <none>, <none>, <none>
  38. 1a P 1 p P -1 -1 -1 // LATIN SMALL LETTER P, LATIN CAPITAL LETTER P, <none>, <none>, <none>
  39. 1b OEM_4 0 0025 0040 -1 -1 -1 // PERCENT SIGN, COMMERCIAL AT, <none>, <none>, <none>
  40. 1e A 1 a A -1 -1 -1 // LATIN SMALL LETTER A, LATIN CAPITAL LETTER A, <none>, <none>, <none>
  41. 1f S 1 s S -1 -1 -1 // LATIN SMALL LETTER S, LATIN CAPITAL LETTER S, <none>, <none>, <none>
  42. 20 D 1 d D -1 -1 -1 // LATIN SMALL LETTER D, LATIN CAPITAL LETTER D, <none>, <none>, <none>
  43. 21 F 1 f F -1 -1 -1 // LATIN SMALL LETTER F, LATIN CAPITAL LETTER F, <none>, <none>, <none>
  44. 22 G 1 g G -1 -1 -1 // LATIN SMALL LETTER G, LATIN CAPITAL LETTER G, <none>, <none>, <none>
  45. 23 OEM_7 0 0027 0022 -1 00a8@ -1 // APOSTROPHE, QUOTATION MARK, <none>, DIAERESIS, <none>
  46. 24 H 1 h H -1 -1 -1 // LATIN SMALL LETTER H, LATIN CAPITAL LETTER H, <none>, <none>, <none>
  47. 25 J 1 j J -1 -1 -1 // LATIN SMALL LETTER J, LATIN CAPITAL LETTER J, <none>, <none>, <none>
  48. 26 K 1 k K -1 -1 -1 // LATIN SMALL LETTER K, LATIN CAPITAL LETTER K, <none>, <none>, <none>
  49. 27 L 1 l L -1 -1 -1 // LATIN SMALL LETTER L, LATIN CAPITAL LETTER L, <none>, <none>, <none>
  50. 28 OEM_1 4 003b 003a -1 00f1 00d1 // SEMICOLON, COLON, <none>, LATIN SMALL LETTER N WITH TILDE, LATIN CAPITAL LETTER N WITH TILDE
  51. 29 OEM_2 0 003f 0021 -1 00ba 00aa // QUESTION MARK, EXCLAMATION MARK, <none>, MASCULINE ORDINAL INDICATOR, FEMININE ORDINAL INDICATOR
  52. 2b OEM_5 4 007c 0024 -1 00e7 00c7 // VERTICAL LINE, DOLLAR SIGN, <none>, LATIN SMALL LETTER C WITH CEDILLA, LATIN CAPITAL LETTER C WITH CEDILLA
  53. 2c Z 1 z Z -1 -1 -1 // LATIN SMALL LETTER Z, LATIN CAPITAL LETTER Z, <none>, <none>, <none>
  54. 2d X 1 x X -1 -1 -1 // LATIN SMALL LETTER X, LATIN CAPITAL LETTER X, <none>, <none>, <none>
  55. 2e C 1 c C -1 -1 -1 // LATIN SMALL LETTER C, LATIN CAPITAL LETTER C, <none>, <none>, <none>
  56. 2f V 1 v V -1 -1 -1 // LATIN SMALL LETTER V, LATIN CAPITAL LETTER V, <none>, <none>, <none>
  57. 30 B 1 b B -1 -1 -1 // LATIN SMALL LETTER B, LATIN CAPITAL LETTER B, <none>, <none>, <none>
  58. 31 OEM_3 0 007e 0026 -1 -1 -1 // TILDE, AMPERSAND, <none>, <none>, <none>
  59. 32 N 1 n N -1 -1 -1 // LATIN SMALL LETTER N, LATIN CAPITAL LETTER N, <none>, <none>, <none>
  60. 33 M 1 m M -1 -1 -1 // LATIN SMALL LETTER M, LATIN CAPITAL LETTER M, <none>, <none>, <none>
  61. 34 OEM_COMMA 0 002c 0023 -1 -1 -1 // COMMA, NUMBER SIGN, <none>, <none>, <none>
  62. 35 OEM_PERIOD 0 002e 002a -1 -1 -1 // FULL STOP, ASTERISK, <none>, <none>, <none>
  63. 39 SPACE 0 0020 0020 -1 -1 -1 // SPACE, SPACE, <none>, <none>, <none>
  64. 53 DECIMAL 0 002e 002e -1 -1 -1 // FULL STOP, FULL STOP, , ,
  65. DEADKEY 00b4
  66. 0061 00e1 // a -> á
  67. 0065 00e9 // e -> é
  68. 0069 00ed // i -> í
  69. 006f 00f3 // o -> ó
  70. 0075 00fa // u -> ú
  71. 0079 00fd // y -> ý
  72. 0041 00c1 // A -> Á
  73. 0045 00c9 // E -> É
  74. 0049 00cd // I -> Í
  75. 004f 00d3 // O -> Ó
  76. 0055 00da // U -> Ú
  77. 0059 00dd // Y -> Ý
  78. 0020 00b4 // -> ´
  79. DEADKEY 00a8
  80. 0061 00e4 // a -> ä
  81. 0065 00eb // e -> ë
  82. 0069 00ef // i -> ï
  83. 006f 00f6 // o -> ö
  84. 0075 00fc // u -> ü
  85. 0041 00c4 // A -> Ä
  86. 0045 00cb // E -> Ë
  87. 0049 00cf // I -> Ï
  88. 004f 00d6 // O -> Ö
  89. 0055 00dc // U -> Ü
  90. 0079 00ff // y -> ÿ
  91. 0020 00a8 // -> ¨
  92. KEYNAME
  93. 01 Esc
  94. 0e Backspace
  95. 0f Tab
  96. 1c Enter
  97. 1d Ctrl
  98. 2a Shift
  99. 36 "Right Shift"
  100. 37 "Num *"
  101. 38 Alt
  102. 39 Space
  103. 3a "Caps Lock"
  104. 3b F1
  105. 3c F2
  106. 3d F3
  107. 3e F4
  108. 3f F5
  109. 40 F6
  110. 41 F7
  111. 42 F8
  112. 43 F9
  113. 44 F10
  114. 45 Pause
  115. 46 "Scroll Lock"
  116. 47 "Num 7"
  117. 48 "Num 8"
  118. 49 "Num 9"
  119. 4a "Num -"
  120. 4b "Num 4"
  121. 4c "Num 5"
  122. 4d "Num 6"
  123. 4e "Num +"
  124. 4f "Num 1"
  125. 50 "Num 2"
  126. 51 "Num 3"
  127. 52 "Num 0"
  128. 53 "Num Del"
  129. 54 "Sys Req"
  130. 57 F11
  131. 58 F12
  132. 7c F13
  133. 7d F14
  134. 7e F15
  135. 7f F16
  136. 80 F17
  137. 81 F18
  138. 82 F19
  139. 83 F20
  140. 84 F21
  141. 85 F22
  142. 86 F23
  143. 87 F24
  144. KEYNAME_EXT
  145. 1c "Num Enter"
  146. 1d "Right Ctrl"
  147. 35 "Num /"
  148. 37 "Prnt Scrn"
  149. 38 "Right Alt"
  150. 45 "Num Lock"
  151. 46 Break
  152. 47 Home
  153. 48 Up
  154. 49 "Page Up"
  155. 4b Left
  156. 4d Right
  157. 4f End
  158. 50 Down
  159. 51 "Page Down"
  160. 52 Insert
  161. 53 Delete
  162. 54 <00>
  163. 56 Help
  164. 5b "Left Windows"
  165. 5c "Right Windows"
  166. 5d Application
  167. KEYNAME_DEAD
  168. 00b4 "ACUTE ACCENT"
  169. 00a8 "DIAERESIS"
  170. DESCRIPTIONS
  171. 0409 QWERT^(VK code, Modifiers and Symmetrical numbers) - CN
  172. LANGUAGENAMES
  173. 0409 Chinese (People's Republic of China)
  174. ENDKBD
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注