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?
Best Answer
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: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:
was:
So in the position of
O
in my layout, it is interpreted asVK_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