| Getting Unusual Keyboard Keys to Work |
Back |
Since I first used an IBM PC (running OS/2), I had an IBM Clicky Keyboard at my desk. And when we moved to Dell PC's the first more modern keyboards were supplied. I kept my old IBM keyboard. Later, when I saw dozens of the old IBM keyboards in the trash, I took about 4 home and a couple still work 100% today, including this one at my desk today:
This one has a manufacturing date of 16DEC87 on the back so it's pretty old. In fact, that red tag was the first attempt at hardware inventory control where I worked, done simply with a Dymo labelmaker.
The keyboard map image in Vista is of course based on that IBM keyboard layout:

Your keyboard may be different. It may be more modern with additional keys that might be useful, or it may be from another country. You may even find one like this user's 3270-style keyboard, with an extra row of PF keys at the top:
Getting Keys To Work with Vista
When you press a key, a standard keyboard driver program is interrupted, and the keyscancode produced by that key is passed to the active window, in this case Vista. This byte can be displayed by adding the &keyscancode variable to the Status Line text in Vista, such as:
With that variable set, every time you press a key you should see a byte displayed in hex at the bottom left of the Vista window, such as the 20 below, when I press the Space bar:
Note that if you press a key that produces NO keyscancode, in this case the 20 will remain (i.e. whatever was previously pressed). So be careful and don't assume a particular key is active or not.
If the key you want to enable produces no change in the keyscancode, then there's nothing Vista can do to get that key to work. My impression is that a special keyboard driver may be necessary, so look into that if possible.
FYI - The top row of PF keys in the 3270-style keyboard above produced no keyscancodes for that user, so without a driver program, sorry, those keys are just to look pretty.
Translating the KeyScanCode to the Vista Internal Key Code
If you do get a keyscancode change, but Vista doesn't seem to respond to the keypress, then you'll need to know a bit about how Vista handles keypresses. The keyscancode is first translated to a Vista Internal Key Code, via this table:
KeyScanCodes
* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF
*--------------------------------------------------------------------------
ff 65 66 67 68 74 75 ff 1d 25 ff ff 16 46 ff ff * 0x
4a 5b 5c 0f 3a ff ff ff ff ff ff 00 ff ff ff ff * 1x
5d 20 35 34 1f 60 56 62 61 ff ff ff 0d 1e 33 ff * 2x
1a 11 12 13 14 15 16 17 18 19 ff ff ff ff ff ff * 3x
ff 3b 4f 4d 3d 28 3e 3f 40 2d 41 42 43 51 50 2e * 4x
2f 26 29 3c 2a 2c 4e 27 4c 2b 4b ff ff ff ff ff * 5x
63 57 58 59 47 48 49 36 37 38 23 39 ff 24 64 22 * 6x
01 02 03 04 05 06 07 08 09 0a 0b 0c ff ff ff ff * 7x
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff * 8x
21 0e ff ff ff ff ff ff ff ff ff ff ff ff ff ff * 9x
ff ff ff ff ff ff ff ff ff ff ff ff 48 5a ff ff * Ax
55 5f 5e ff ff ff ff ff ff ff 44 1c 52 1b 53 54 * Bx
10 38 59 57 36 47 37 49 58 ff ff ff ff 63 64 ff * Cx
ff ff ff ff ff ff ff ff ff ff ff 30 32 31 45 ff * Dx
ff ff 76 ff ff ff ff 3b ff ff ff ff ff ff ff ff * Ex
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff * Fx
This table is located in file country.lst, in the exe install directory, usually
c:\Program Files (x86)\TomBrennanSoftware\VistaTN3270
So with the x'20' from the space bar, we go to the first entry in the second column and come up with x'5D' as the l Vista Internal Key Code. Note that if we come up with x'FF' as the internal key code, that's considered a null code an no action is taken. This is an important point because that could be what is preventing your paricular keyscancode from doing anything.
So why use internal key code x'5D' for the space bar? What's up with that? That was just my way of simplifying they key assignment process. x'5D' is 93 in decimal, and if you count the keys on my original IBM keyboard, starting with Esc as zero, from left to right and top to bottom, they space bar is key number 93. This translation made programming such as standard.key lookup and the keyboard editor much easier for me.
Translating the Internal Key Code to do Useful Work
Once we have the Internal Key Code, we need to look it up in the *.key file (default standard.key) which contains a list of actions for each internal key code. In fact, the standard.key file contains FOUR actions, potentially each different, for each internal key code. These actions are "normal, shift, ctrl, and alt", depending on if you are holding down one of those shifter keys while pressing the key.
FYI - To simply the program, and also make things more easy to remember for the user, Vista only has functions for those individual shifter keys (shift, ctrl, and alt). Vista DOES NOT support using multiple keys such as shift and ctrl held down together, to form yet another key action option.
File standard.key is binary, but if you want to take a look download file vistaformat.exe and copy it to your Documents\TomBrennanSoftware\VistaTN3270 directory. It's a DOS command so you'll need to open a DOS window, cd to your Documents folder (mine listed below) and run the program such as:
c:\Users\Tom\Documents\TomBrennanSoftware\VistaTN3270>vistaformat standard.key
Format of KEY file standard.key
Num Key Name Shift Type I R Function
--- -------- -------- -------- - - -----------------------
0 Escape Normal Action 1 0 Attention
0 Escape Shift Action 1 0 SysRequest
0 Escape Ctrl Action 1 0 Attention
0 Escape Alt Action 1 0 Attention
1 F1 Normal Action 0 0 PF1
1 F1 Shift Action 0 0 PF13
1 F1 Ctrl Action 0 0 PF13
1 F1 Alt Oper 1 1 NextSession
2 F2 Normal Action 0 0 PF2
2 F2 Shift Action 0 0 PF14
2 F2 Ctrl Action 0 0 PF14
2 F2 Alt Oper 1 1 PrevSession
With that you can see each of the 4 Shift options for each key. Escape, for example, is Internal Key Code zero, and has the functions Attention or SysRequest depending on the shifter keys held. These settings of course, can be edited using the keyboard editor in Vista, since it's a binary file.
The "Type" column indicates what type of work needs to be performed. These are the same as the tabs at the top of the assignment window in the keyboard editor, such as:
Action keys are keys that send data or interrupt the host, such as pressing Enter, Clear, etc.
Edit keys change the screen, such as copy/paste, moving the cursor, etc. but without sending data to the host.
Char keys are simply characters A-Z, etc. that change the screen but do not send them to the host.
Oper functions are various activities you might want to do in Vista, such as maximizing the screen, etc.
Macro functions let you assign a Vista macro to a key/
The "I" column stands for Immediate, which means that the key action will be done even if the keyboard is currently locked by the host. Obviously we want Attention and SysRequest to function in that way. But F1 should only be run if the keyboard is unlocked, so the "I" column is zero for that keypress. The "R" option means that key Repeat is active. Normally we would not want to repeat Attention or F1, but we might want to repeat the NextSession function. These flags are also editable using the keyboard editor in Vista, if needed.
Tracing Key Press to Function
So let's go back to our Space Bar keypress.
KeyScanCode = x'20', so we convert that using the KeyScanCode table in country.lst to x'5D' or 93.
Then we look up key 93 in the active *.key file, in this case standard.lst, which we can format as:
93 Space Normal Char 0 1
93 Space Shift Char 0 1
93 Space Ctrl Char 0 1
93 Space Alt Char 0 1
And the program would run Char processing and add a space to the screen and then move the cursor. Simple.
Trying to Enable a Key that Currently Does Nothing
Ok, now that I've described the way things are supposed to work, let's try an example of trying to make a dead key work on your keyboard.
Let's say you added the &keyscancode variable, press the space key, and x'20' appears as expected. Then you press a key on your keyboard that doesn't do anything, but x'85' appears. That means we have a good chance of enabling that key to do useful work.
So now we need to look up x'85' in the KeyScanCodes table and we find x'FF'. Remember that x'FF' tells Vista this key is not active.
KeyScanCodes
* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF
*--------------------------------------------------------------------------
ff 65 66 67 68 74 75 ff 1d 25 ff ff 16 46 ff ff * 0x
4a 5b 5c 0f 3a ff ff ff ff ff ff 00 ff ff ff ff * 1x
5d 20 35 34 1f 60 56 62 61 ff ff ff 0d 1e 33 ff * 2x
1a 11 12 13 14 15 16 17 18 19 ff ff ff ff ff ff * 3x
ff 3b 4f 4d 3d 28 3e 3f 40 2d 41 42 43 51 50 2e * 4x
2f 26 29 3c 2a 2c 4e 27 4c 2b 4b ff ff ff ff ff * 5x
63 57 58 59 47 48 49 36 37 38 23 39 ff 24 64 22 * 6x
01 02 03 04 05 06 07 08 09 0a 0b 0c ff ff ff ff * 7x
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff * 8x
21 0e ff ff ff ff ff ff ff ff ff ff ff ff ff ff * 9x
ff ff ff ff ff ff ff ff ff ff ff ff 48 5a ff ff * Ax
55 5f 5e ff ff ff ff ff ff ff 44 1c 52 1b 53 54 * Bx
10 38 59 57 36 47 37 49 58 ff ff ff ff 63 64 ff * Cx
ff ff ff ff ff ff ff ff ff ff ff 30 32 31 45 ff * Dx
ff ff 76 ff ff ff ff 3b ff ff ff ff ff ff ff ff * Ex
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff * Fx
So in this case we will need to change the x'FF' to an Internal Key Code, but which one? We know Internal Key Codes are simply the keys being numbered from left to right and top to bottom on my IBM keyboard. So there are only that many Internal Key Codes available. We need to choose something currently not used.
For example, let's say your keyboard lacks the numeric pad over to the right. In that case, we have a lot of Internal Key Codes we can "borrow". Let's choose the dash at the upper right of the numeric pad:
The vistaformat command shows that key "Num -" as Internal Key Code #36
36 Num - Normal Char 0 1 -
36 Num - Shift Char 0 1 -
36 Num - Ctrl Char 0 1 -
36 Num - Alt Char 0 1 -
... so let's use that. 36 in hex is x'24', so we'll need to edit the KeyScanCode table in country.lst as:
KeyScanCodes
* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF
*--------------------------------------------------------------------------
ff 65 66 67 68 74 75 ff 1d 25 ff ff 16 46 ff ff * 0x
4a 5b 5c 0f 3a ff ff ff ff ff ff 00 ff ff ff ff * 1x
5d 20 35 34 1f 60 56 62 61 ff ff ff 0d 1e 33 ff * 2x
1a 11 12 13 14 15 16 17 18 19 ff ff ff ff ff ff * 3x
ff 3b 4f 4d 3d 28 3e 3f 40 2d 41 42 43 51 50 2e * 4x
2f 26 29 3c 2a 2c 4e 27 4c 2b 4b ff ff ff ff ff * 5x
63 57 58 59 47 48 49 36 37 38 23 39 ff 24 64 22 * 6x
01 02 03 04 05 06 07 08 09 0a 0b 0c ff ff ff ff * 7x
ff ff ff ff ff 24 ff ff ff ff ff ff ff ff ff ff * 8x
21 0e ff ff ff ff ff ff ff ff ff ff ff ff ff ff * 9x
ff ff ff ff ff ff ff ff ff ff ff ff 48 5a ff ff * Ax
55 5f 5e ff ff ff ff ff ff ff 44 1c 52 1b 53 54 * Bx
10 38 59 57 36 47 37 49 58 ff ff ff ff 63 64 ff * Cx
ff ff ff ff ff ff ff ff ff ff ff 30 32 31 45 ff * Dx
ff ff 76 ff ff ff ff 3b ff ff ff ff ff ff ff ff * Ex
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff * Fx
Note that you'll probably need Admin authority to save country.lst in c:\Program Files (x86)\* so be ready for that. Also, you'll need to restart Vista after changing country.lst
Also note that if a keyscancode arrives as x'6D' that would also result in Internal Key Code x'24' since that's still in the table above. But for this exercise, let's assume there is no numeric pad on the user's keyboard.
Once this is done, you should hopefully see a dash when you press your unusual key, supplied by the default standard.key settings for Internal Key Code 36. At that point, you can edit that Num - key using the keyboard editor to whatever you want to use that key for, such as this example:
But of course those changes should affect your special key.
Good luck!
|