2

My goal:

I am trying to get the MS Keyboard Layout Creator to allow me to perform a carriage return/enter whenever I hit the [R-Arrow] key in combination with the [Control] key, but still have the [R-Arrow] key perform as normal (i.e. move one character right) when hit alone. I'm doing this because my laptop keyboard [Enter] key is busted, and I want use this hack for a short time, before I go ahead and get another keyboard. Yes, I know it might be easier to get a new one. :)

As far as I can tell, I have almost figured everything out. The only pieces of information I still need are the exact hexadecimal codepoints for both the 1) right arrow navigation and 2) enter/carriage-return. I am hoping someone can direct me to this info. I have found the unicode reference but I am unable to discern which codes I might use for the carriage return and the right arrow navigation (not the right arrow ascii character , I don't care about that)

Example code in my existing KLC file:

KBD Layout01    "Layout01 Description"
COPYRIGHT   "(c) 2017 Company"
COMPANY "Company"
LOCALENAME  "en-US"
LOCALEID    "00000409"
VERSION 1.0
SHIFTSTATE
0   //Column 4
1   //Column 5 : Shft
2   //Column 6 :       Ctrl
LAYOUT      ;an extra '@' at the end is a dead key

//SC    VK_     Cap 0   1   2
//--    ----        ----    ----    ----    ----
39  SPACE       0   0020    0020    -1      // SPACE, SPACE, <none>
53  DECIMAL 0   002e    002e    -1      // FULL STOP, FULL STOP,

My understanding of the code (SPACEBAR example)

Looking at the preexisting examples in the file, (the space and the decimal) I have figured out the following:

Note: the examples in parentheses below refer only to the spacebar.

  1. The first number is the keyboard key (e.g. 39 above)
  2. The word which follows that number is the designated label to refer to that key (e.g. SPACE above)
  3. the next three numbers are hexadecimal codepoints/symbols which refer to "SHIFTSTATES"
    1. The first is the codepoint for what the key will output if pressed while the CAPSLOCK is pressed.
    2. The second is the codepoint for what the key will output if pressed simultaneously with the SHIFT key.
    3. The third is the codepoint for what the key will output if pressed simultaneously with the CONTROL key.

The goal: figuring out the codes for right-arrow navigation and enter

I have figured out this much for my line of code that I want to add in order so that pressing the right key alone will still navigate right, but in wihc the combination "control-right" will instead trigger a carriage-return/enter

4d RIGHT 0 ??I don't know?? ??I don't know?? -1

I believe the I know following

  1. 4d (in the 1st column) is the key code for the right arrow key
  2. the handle RIGHT (in the 2nd column) is the handle/name for the right arrow
  3. 0 (in the 3rd column means don't change the key if the capslock is pressed

What I need your help to figure out

  1. What the codepoint/hexadecimal/unicode symbol is for performing a right arrow navigation (I think that is what goes in the fourth column if I want [Shift]-[Right-Arrow] to make the cursor move one character to the right).
  2. What the codepoint/hexadecimal/unicode symbol is for performing a carriage-return/enter(I think that is what goes in the fifth column if I want [Control]-[Right-Arrow] to trigger an enter/carriage-return).

It may be that I am mistaken and the symbols I need are not unicode codepoints; if I am wrong, please correct me, as that info will help me get closer to my goal. Any help would be greatly appreciated!

Community
  • 1
  • 1
CoderScissorhands
  • 485
  • 1
  • 6
  • 26

1 Answers1

2

I don't know if you still need this, as I had already written down most of it I post it.


I looked into it for a while, I haven't found an actual definitive answer but I can give you some hints (I post this as an answer nonetheless because it would have been too unwieldy to use comments).


I have a strong feeling that what you ask is not possible (that control keys such as the arrows cannot be mapped to different keys/characters/functions when a modifier such as ctrl is pressed).

I'm not really a huge expert in these things but I can give you some pointers:

  1. (in the following there is a good deal of information not much related to your problem, but it might help you understand better)

    When you press a key in Windows there are at least 3 sets of codes that are involved:

    1. Scan codes: these are the codes that are actually generated by the hardware and sent to the pc. I have little knowledge of them, I never had a need to use them and I was too young when they were more relevant. They can theoretically vary from keyboard to keyboard but they're largely standardized; the USB keyboards are really standardized, for what I could understand, and their scan codes ought to be those listed in these HID Usage Tables (section 10). Wikipedia has some info but not a full list of the traditional codes. Most likely you won't need these, though (but maybe you will). By the way, these scan codes are also passed to the applications (I'm not sure how reliably) but they hardly ever use them.
    2. Virtual-key codes: The scan codes in Windows are translated by the keyboard driver into a common set of key codes specified by Microsoft: the Virtual-Key Codes. These are independent by the keyboard and are what's (normally) used by the applications when they need to handle the single key presses.
    3. Unicode, or other charset, characters: Windows recognizes when the keys being pressed are supposed to produce printable characters and passes these characters to the applications. At the times when an application is only interested in printable characters it only looks at these characters, although when they need to do more complex things (shortcuts...) they also have access to the virtual-key codes (and, if they really want, to the scan codes). Unicode is a character set, not a "key-codes set", so it generally contains only printable characters. To facilitate interoperability with ASCII and other legacy charsets it also includes the control characters defined in previous standards, but among these control characters the arrow keys are not present, so there are no unicode codepoints for the keyboard's arrows.
  2. In the second column of the klc it would appear that you have to put the name of the virtual-key constant with VK_ removed. Quite weird indeed.

  3. Several Microsoft documentation pages say that the WDK kbd.h file that you can also find in the inc directory of the Microsoft Keyboard Layout Creator has the detailed information about this stuff. Personally I couldn't make too much out of it, though.

  4. If you really want to dig into this the late Michael Kaplan's blog has probably the information you're looking for, somewhere.

  5. Your best luck is most likely to use some other application. I stumbled upon KbdEdit, that does handle the arrow keys, but it really seems that it can't assign a different function to the key when used with a modifier (but you can change the effect of the key altogether, irrespective of the pressed modifier).

  6. For the Enter key you would likely need to use the virtual key, which is 0D (VK_RETURN).

  7. The sequence of characters used to indicate line breaks on Windows is CR LF, which have (in Unicode and almost every other existing charset) codepoints 0D 0A, respectively.
    The Windows message that notifies applications of entered characters (point 1.3 above - I mean the WM_CHAR message, by the way) though reports only a CR (0D) when you press Enter; so if those klf files use unicode codepoints in some part there's a good chance that they use that (CR) to indicate a Enter key.


All in all, your best bet is probably to just assign the Enter to a different key (for example a function key, the right ctrl or win key if you have them or the caps-lock).

gbr
  • 1,264
  • 8
  • 27