Friday, August 6, 2010

How to fix keyboard shortcuts in KLC (e.g. Ctrl+S)

I recently created my own keyboard layout using Microsoft Keyboard Layout Creator. Everything was working fine until I tried using a shortcut such as Ctrl+S. Instead of saving the document, it used the underlying Qwerty keyboard key. In this case it was Ctrl+;, which didn't do anything. A day or so later, I read this article by Michael Capewell, where he mentions that he was able to fix the keyboard shortcuts. I sent him an email asking how to do just that, and this is what I found out...

To restore keyboard shortcuts in Microsoft KLC:

  1. Create the keyboard as you normally would in KLC.
  2. Save the layout as a .klc file.
  3. Open the .klc file in a text editor.
  4. For each key that was moved, you need to update the VK_ column to reflect this change as well, since KLC doesn't do this for you. See the list at the end of this post to see the valid values.

    For example, if you are changing L to N, you would change line 3:

    //SC    VK_             Cap     0       1       2
    //--    ----            ----    ----    ----    ----
    26      L               1       n       N       -1              // LATIN SMALL LETTER N, LATIN CAPITAL LETTER N, <none>
    

    to:

    //SC    VK_             Cap     0       1       2
    //--    ----            ----    ----    ----    ----
    26      N               1       n       N       -1              // LATIN SMALL LETTER N, LATIN CAPITAL LETTER N, <none>
    

    ... by simply replacing 1 letter, L with N, in the VK_ column.

    Note: You cannot repeat a VK_ value. If you do, it will only take the first one and the other key will not be assigned to anything. You will get warnings about this when you try to build your keyboard.

  5. Open the .klc in Microsoft Keyboard Layout Creator.
  6. Build and install your keyboard as you normally would.

Which values can I use in the VK_ column?

The default VK_ values that can be used are:

  • A ... Z - The keys representing A to Z.
  • 0 ... 9 - The keys at the top of your keyboard (not the Numpad) that represent 0 to 9.
  • OEM_PLUS - +
  • OEM_COMMA - ,
  • OEM_PERIOD - .
  • OEM_1 - ; :
  • OEM_2 - / ?
  • OEM_3 - ` ~
  • OEM_4 - [ {
  • OEM_5 - \ |
  • OEM_6 - ] }
  • OEM_7 - ' "
  • OEM_MINUS - -
  • SPACE -          
  • DECIMAL - . on Numpad

See this document for more information.

Thanks to Michael Capewell for explaining the process.

5 comments:

  1. You saved my day! Actually, not just one day, but a good many days of research into this matter. I have discovered it is not just with CTRL+key but also within the Flash player in a browser.

    Using your solution it is completely fixed. Thank you!!!

    ReplyDelete
  2. Thank you so much! I was tearing my hair out until I saw your answer on superuser.

    ReplyDelete
  3. That has been my problem as well. Glad you emailed him and you were able to share how to fix keyboard shortcuts in KLC.

    membrane switch

    ReplyDelete
  4. how do i set if i wanna change ` button to alt+s

    ReplyDelete
  5. Thank you so much, you also really saved my day!
    Note that you have to be very carefull not to assign twice the same VK, or to assign non existing VK: for me, it leads to errors preventing to build the keyboard.

    ReplyDelete