3

In Windows 10, I use Microsoft Keyboard Layout Creator to change my keyboard layout, so half of my keys change place.

But now, all the keyboard shortcuts in my software will not work. For example, now in the location where the P key was, there is O. In Eclipse, when I press Ctrl+O to open a method, Eclipse thinks that I am pressing Ctrl+P so it prompts me the print dialog.

In MS site I read this:

https://msdn.microsoft.com/en-us/library/windows/desktop/gg153546(v=vs.85).aspx

Also, avoid using WM_CHAR to implement keyboard shortcuts. Instead, use WM_KEYDOWN messages; or even better, use an accelerator table. Accelerator tables are described in the next topic, Accelerator Tables.

So, when I change the keyboard layout, I change the char of every key, but I didn't change the virtual-key code, so this is messed up. The same applies to IME(input methods), like Microsoft Pinyin. Now, with new keyboard layout, I cannot go to next page with , and previous page with ..

Now it becomes understandable, while staying being unreasonable.

I think there must be a solution, because I think I face the same problem which any user wanting to use Dvorak or AZERTY or any other keyboard layout.

How can we solve this?

3

I have found another very related question here:

How can I restore Ctrl+<key> functionality in Microsoft Keyboard Layout Creator?

, which has a perfect answer. I will try to expand it with details and put it here as a copy.

The answer mentions changing the VK code of every key by editing the .klc file directly in a text editor, which I haven't think about, amazing design. It also contains a link to a blog showing how to do it:

www.sensefulsolutions.com/2010/08/how-to-fix-keyboard-shortcuts-in-klc-eg.html

So let's say it like this:

The shortcuts in every application in Windows are bind not directly to the character output of each key. They are bind to the Virtual Key code of every key. The scan code of keys are hardware specific. The driver converts these code into virtual key code, and then the OS receive VK code to do tasks.

When we edit a keyboard layout in MSKLC, the VK code are not changed by default. But you can open the .klc file to edit it.

A typical .klc file will be like this:

KBD WT_VK_CN    "WindThunder VK code changed - Simplified Chinese"

COPYRIGHT   "(c) 2017 WindThunder Studio"

COMPANY "WindThunder Studio"

LOCALENAME  "zh-CN"

LOCALEID    "00000804"

VERSION 1.0

SHIFTSTATE

0   //Column 4
1   //Column 5 : Shft
2   //Column 6 :       Ctrl
6   //Column 7 :       Ctrl Alt
7   //Column 8 : Shft  Ctrl Alt

LAYOUT      ;an extra '@' at the end is a dead key

//SC    VK_     Cap   0     1        2   6       7
//----------------------------------------------------------------------------------------------------------------------------

02  1           1   007b    1       -1  -1      -1      // LEFT CURLY BRACKET, DIGIT ONE, <none>, <none>, <none>
03  2           1   005b    2       -1  00b7    -1      // LEFT SQUARE BRACKET, DIGIT TWO, <none>, MIDDLE DOT, <none>
04  3           1   0028    3       -1  20ac    -1      // LEFT PARENTHESIS, DIGIT THREE, <none>, EURO SIGN, <none>
05  4           1   003c    4       -1  -1      -1      // LESS-THAN SIGN, DIGIT FOUR, <none>, <none>, <none>
06  5           1   002f    5       -1  -1      -1      // SOLIDUS, DIGIT FIVE, <none>, <none>, <none>
07  OEM_7       0   0027    0022    -1  00a8@   -1      // APOSTROPHE, QUOTATION MARK, <none>, DIAERESIS, <none>
08  6           1   005c    6       -1  00ac    -1      // REVERSE SOLIDUS, DIGIT SIX, <none>, NOT SIGN, <none>
09  7           1   003e    7       -1  -1      -1      // GREATER-THAN SIGN, DIGIT SEVEN, <none>, <none>, <none>
0a  8           1   0029    8       -1  -1      -1      // RIGHT PARENTHESIS, DIGIT EIGHT, <none>, <none>, <none>
0b  9           1   005d    9       -1  -1      -1      // RIGHT SQUARE BRACKET, DIGIT NINE, <none>, <none>, <none>
0c  0           1   007d    0       -1  00a1    -1      // RIGHT CURLY BRACKET, DIGIT ZERO, <none>, INVERTED EXCLAMATION MARK, <none>
0d  OEM_PLUS    0   003d    002b    -1  00bf    -1      // EQUALS SIGN, PLUS SIGN, <none>, INVERTED QUESTION MARK, <none>
10  Q           1   q       Q       -1  -1      -1      // LATIN SMALL LETTER Q, LATIN CAPITAL LETTER Q, <none>, <none>, <none>
11  W           1   w       W       -1  -1      -1      // LATIN SMALL LETTER W, LATIN CAPITAL LETTER W, <none>, <none>, <none>
12  E           1   e       E       -1  -1      -1      // LATIN SMALL LETTER E, LATIN CAPITAL LETTER E, <none>, <none>, <none>
13  R           1   r       R       -1  -1      -1      // LATIN SMALL LETTER R, LATIN CAPITAL LETTER R, <none>, <none>, <none>
14  T           1   t       T       -1  -1      -1      // LATIN SMALL LETTER T, LATIN CAPITAL LETTER T, <none>, <none>, <none>
15  OEM_6       0   0060    005e    -1  00b4@   -1      // GRAVE ACCENT, CIRCUMFLEX ACCENT, <none>, ACUTE ACCENT, <none>
16  Y           1   y       Y       -1  -1      -1      // LATIN SMALL LETTER Y, LATIN CAPITAL LETTER Y, <none>, <none>, <none>
17  U           1   u       U       -1  -1      -1      // LATIN SMALL LETTER U, LATIN CAPITAL LETTER U, <none>, <none>, <none>
18  I           1   i       I       -1  -1      -1      // LATIN SMALL LETTER I, LATIN CAPITAL LETTER I, <none>, <none>, <none>
19  O           1   o       O       -1  -1      -1      // LATIN SMALL LETTER O, LATIN CAPITAL LETTER O, <none>, <none>, <none>
1a  P           1   p       P       -1  -1      -1      // LATIN SMALL LETTER P, LATIN CAPITAL LETTER P, <none>, <none>, <none>
1b  OEM_MINUS   0   0025    0040    -1  -1      -1      // PERCENT SIGN, COMMERCIAL AT, <none>, <none>, <none>
1e  A           1   a       A       -1  -1      -1      // LATIN SMALL LETTER A, LATIN CAPITAL LETTER A, <none>, <none>, <none>
1f  S           1   s       S       -1  -1      -1      // LATIN SMALL LETTER S, LATIN CAPITAL LETTER S, <none>, <none>, <none>
20  D           1   d       D       -1  -1      -1      // LATIN SMALL LETTER D, LATIN CAPITAL LETTER D, <none>, <none>, <none>
21  F           1   f       F       -1  -1      -1      // LATIN SMALL LETTER F, LATIN CAPITAL LETTER F, <none>, <none>, <none>
22  G           1   g       G       -1  -1      -1      // LATIN SMALL LETTER G, LATIN CAPITAL LETTER G, <none>, <none>, <none>
23  OEM_4       0   002d    005f    -1  -1      -1      // HYPHEN-MINUS, LOW LINE, <none>, <none>, <none>
24  H           1   h       H       -1  -1      -1      // LATIN SMALL LETTER H, LATIN CAPITAL LETTER H, <none>, <none>, <none>
25  J           1   j       J       -1  -1      -1      // LATIN SMALL LETTER J, LATIN CAPITAL LETTER J, <none>, <none>, <none>
26  K           1   k       K       -1  -1      -1      // LATIN SMALL LETTER K, LATIN CAPITAL LETTER K, <none>, <none>, <none>
27  L           1   l       L       -1  -1      -1      // LATIN SMALL LETTER L, LATIN CAPITAL LETTER L, <none>, <none>, <none>
28  OEM_1       4   003b    003a    -1  00f1    00d1    // SEMICOLON, COLON, <none>, LATIN SMALL LETTER N WITH TILDE, LATIN CAPITAL LETTER N WITH TILDE
29  OEM_2       0   003f    0021    -1  00ba    00aa    // QUESTION MARK, EXCLAMATION MARK, <none>, MASCULINE ORDINAL INDICATOR, FEMININE ORDINAL INDICATOR
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
2c  Z           1   z       Z       -1  -1      -1      // LATIN SMALL LETTER Z, LATIN CAPITAL LETTER Z, <none>, <none>, <none>
2d  X           1   x       X       -1  -1      -1      // LATIN SMALL LETTER X, LATIN CAPITAL LETTER X, <none>, <none>, <none>
2e  C           1   c       C       -1  -1      -1      // LATIN SMALL LETTER C, LATIN CAPITAL LETTER C, <none>, <none>, <none>
2f  V           1   v       V       -1  -1      -1      // LATIN SMALL LETTER V, LATIN CAPITAL LETTER V, <none>, <none>, <none>
30  B           1   b       B       -1  -1      -1      // LATIN SMALL LETTER B, LATIN CAPITAL LETTER B, <none>, <none>, <none>
31  OEM_3       0   007e    0026    -1  -1      -1      // TILDE, AMPERSAND, <none>, <none>, <none>
32  N           1   n       N       -1  -1      -1      // LATIN SMALL LETTER N, LATIN CAPITAL LETTER N, <none>, <none>, <none>
33  M           1   m       M       -1  -1      -1      // LATIN SMALL LETTER M, LATIN CAPITAL LETTER M, <none>, <none>, <none>
34  OEM_COMMA   0   002c    0023    -1  -1      -1      // COMMA, NUMBER SIGN, <none>, <none>, <none>
35  OEM_PERIOD  0   002e    002a    -1  -1      -1      // FULL STOP, ASTERISK, <none>, <none>, <none>
39  SPACE       0   0020    0020    -1  -1      -1      // SPACE, SPACE, <none>, <none>, <none>
53  DECIMAL     0   002e    002e    -1  -1      -1      // FULL STOP, FULL STOP, , , 


DEADKEY 00a8

0061    00e4    // a -> ä
0065    00eb    // e -> ë
0069    00ef    // i -> ï
006f    00f6    // o -> ö
0075    00fc    // u -> ü
0041    00c4    // A -> Ä
0045    00cb    // E -> Ë
0049    00cf    // I -> Ï
004f    00d6    // O -> Ö
0055    00dc    // U -> Ü
0079    00ff    // y -> ÿ
0020    00a8    //   -> ¨

DEADKEY 00b4

0061    00e1    // a -> á
0065    00e9    // e -> é
0069    00ed    // i -> í
006f    00f3    // o -> ó
0075    00fa    // u -> ú
0079    00fd    // y -> ý
0041    00c1    // A -> Á
0045    00c9    // E -> É
0049    00cd    // I -> Í
004f    00d3    // O -> Ó
0055    00da    // U -> Ú
0059    00dd    // Y -> Ý
0020    00b4    //   -> ´


KEYNAME

01  Esc
0e  Backspace
0f  Tab
1c  Enter
1d  Ctrl
2a  Shift
36  "Right Shift"
37  "Num *"
38  Alt
39  Space
3a  "Caps Lock"
3b  F1
3c  F2
3d  F3
3e  F4
3f  F5
40  F6
41  F7
42  F8
43  F9
44  F10
45  Pause
46  "Scroll Lock"
47  "Num 7"
48  "Num 8"
49  "Num 9"
4a  "Num -"
4b  "Num 4"
4c  "Num 5"
4d  "Num 6"
4e  "Num +"
4f  "Num 1"
50  "Num 2"
51  "Num 3"
52  "Num 0"
53  "Num Del"
54  "Sys Req"
57  F11
58  F12
7c  F13
7d  F14
7e  F15
7f  F16
80  F17
81  F18
82  F19
83  F20
84  F21
85  F22
86  F23
87  F24

KEYNAME_EXT

1c  "Num Enter"
1d  "Right Ctrl"
35  "Num /"
37  "Prnt Scrn"
38  "Right Alt"
45  "Num Lock"
46  Break
47  Home
48  Up
49  "Page Up"
4b  Left
4d  Right
4f  End
50  Down
51  "Page Down"
52  Insert
53  Delete
54  <00>
56  Help
5b  "Left Windows"
5c  "Right Windows"
5d  Application

KEYNAME_DEAD

00a8    "DIAERESIS"
00b4    "ACUTE ACCENT"


DESCRIPTIONS

0409    WindThunder VK code changed - Simplified Chinese

LANGUAGENAMES

0409    Chinese (People's Republic of China)

ENDKBD

See below the line containing layout. You say a table with lines of mapping of keys and their VK code and the chars output we get when pressing them. The thing we would like to do is to change the second column, VK_, to adapt it to the characters, or change them as you wish. The validation error, if any, will be shown later so don't be nervous to make mistakes.

Before this changed version, the line:

19  O           1   o       O       -1  -1      -1      // LATIN SMALL LETTER O, LATIN CAPITAL LETTER O, <none>, <none>, <none>

was:

19  P           1   o       O       -1  -1      -1      // LATIN SMALL LETTER O, LATIN CAPITAL LETTER O, <none>, <none>, <none>

So in the position of O in my layout, it is interpreted as VK_P, that's why I got print prompt.

A full list of VK_ values is here:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.