Key Mapping Overview
Contents of Article
Deciding on specific chords for your needs
A cautionary note about key mapping
Introduction
The key mapping process requires selecting a specific keyboard key, and assigning a command string to it. You can inspect the mapping of keys individually, or you can use the KEYMAP LIST command to inspect the mapping of all defined keys.
With few exceptions, function keys, alphanumeric keys, and other keys on the keyboard are all treated and mapped in exactly the same way.
You can use nearly any key on the keyboard, and can use that key in any of 8 eight different chords. A chord is a regular key, optionally in combination with the Shift, Control and/or Alt key. (Sometimes, the word chord is meant when at least two of the three keys Shift, Control and Alt are pressed at the same time.) Once you select a physical key for mapping, the definition of every chord for that key can be mapped at the same time, since all eight shift possibilities are displayed on a single screen, as shown below.
For example, the F1 key can be assigned 8 different functions, one each for the chord combinations F1, Shift-F1, Control-F1, Alt-F1, Shift-Control-F1, Shift-Alt-F1, Control-Alt-F1 and Shift-Control-Alt-F1.
What would you do with all those keys? Well, nobody is likely to use them all, but you can use some of them for launching macros and for typing foreign letters and symbols. For example, you could map the lower-case Spanish letter ñ to Ctrl‑N and map the upper-case Spanish letter Ñ to Ctrl‑Shift‑N.
Deciding on specific chords for your needs
When you pick the keys to use for these purposes, the main thing is to choose something that makes sense to you, so you will remember it. You can use any strategy you like, but time and experience have shown that some choices work better than others. Here are some principles to consider:
- If you think of the Shift, Ctrl and Alt keys as "modifier" keys, then the best approach is to use the fewest modifier keys you can to achieve your purpose. The more modifier keys you pick, the harder it is to type.
- Common usage dictates that the Shift key should be included where alphabetic data is involved.
In the example above, we mapped the lower-case Spanish letter ñ to Ctrl‑N and the upper-case Spanish letter Ñ to Ctrl‑Shift‑N. Another reasonable choice would be Alt-N and Alt-Shift-N (although Alt-Shift is harder to type than Ctrl-Shift).
Bear in mind that, on international keyboards that possess an AltGr key, they are designed to transmit the same keyboard data that would occur if you manually held down the Ctrl and Alt keys at the same time. That means, for SPFLite purposes, the single key AltGr and the two keys Ctrl and Alt used together, mean exactly the same thing. By default, SPFLite maps all keys with a printable value (the alpha-numeric and special character keys) so that they will function normally with the AltGr key.
But wait a minute! If I don't have a certain special character mapped to any key, how will I ever get it into the key mappings I want?
If you happen to know the decimal number of the character you want, you can enter it using ALT+0nnn. For example, you can enter an EBCDIC ¬ not sign (X'AC') by holding down the ALT key and typing 0172, where X'AC' = decimal 172.
You have to actually enter the leading 0, or otherwise you get an OEM key value instead of an Ansi value, and for keys that are >= X'80' they won't be right. SPFLite uses Ansi encoding, not OEM encoding, and so 172 and 0172 are not the same character.
This ALT + number technique only works in the KEYMAP GUI entry fields, not in the main SPFLite edit window. That's because SPFLite's extensive key mapping logic would capture any special keys like ALT + a number, and Windows would never see it to convert the number to a character. When you are within a GUI dialog, Windows itself directly manages both the screen and the keyboard input instead of SPFLite, and that's why this technique works. However, once you have a key mapped to some special character, you can use it on the SPFLite editor screen just fine.
The easiest way to get special characters is to use a character map.
SPFLite now also supports its own character map. In the Key Map display, there is a button on the lower right corner of the screen, “Show Character map”. If you click on this button, you will see a pop-up display with a 16 by 16 grid of characters, something like this:
An advantage of this display is that SPFLite uses the same font for this as is used for your edit screen; so it better reflects what you will really see for the chosen character(s). The specific characters available and their appearance depend on the display font you have chosen; the pop-up above shows the RASTER font, available from SPFLite as a download.
Alternate Character Sets
The character display shown by SPFLite is sensitive to the character set you have specified via the SOURCE setting. For example, if you display the character map while working on an EBCDIC file, the display will show the EBCDIC character set, and will place appropriate characters into the clipboard based on the in-use character set. The display shown may be in another collating sequence (either EBCDIC or user-defined), and will report characters placed into the Clipboard based on their collating sequence. Storing an ASCII zero will be reported as X'30' while an EBCDIC zero will be reported as X'F0'.
Once this display appears, you place characters into the clipboard as follows:
Using the left mouse button, click on any desired character in the grid. Any prior contents of the clipboard are erased and replaced by the single character just clicked.
Using the right mouse button, click on any desired character in the grid. The prior contents of the clipboard are retained, and the single character just clicked is appended to the end of the clipboard.
Note that this same display can be brought up and used in an edit session by means of the keyboard primitive function (CharSet), which you would have to map to a key of your choice. For example, suppose you mapped Ctrl-Shift-A to (CharSet). Then, while editing a file, if you needed a special character inserted, press Ctrl-Shift-A, and this window will appear. You then place the desired key(s) into the clipboard, dismiss the window by clicking on the X, and then paste the character(s) into the desired location, which for most users would be done by pressing Ctrl-V (or using the right mouse button, if you have configured your mouse to operate that way).
Finally, you can use SPFLite itself to create special characters by editing in HEX mode. Once you have composed the characters you want, set HEX OFF, and then using the mouse or cursor keys, highlight the desired text and copy it into the clipboard.
As mentioned previously, not just function keys can be mapped, but almost any key can be user-customized. Which keys cannot be mapped? An obvious one is Ctrl-Alt-Delete. Any key sequence that Windows has reserved for its own uses can't be mapped. SPFLite has marked some of these as This entry is Reserved, Do NOT use. Even if SPFLite itself doesn't mark or prevent you from mapping a reserved key, your system may still prevent its use.
Some key sequences used in Microsoft software are merely conventions, and strictly speaking, are not “reserved”. For example, Microsoft uses Ctrl-C for “copy” and Ctrl-V for “paste”, but these are just conventions; they are not reserved. You can map Ctrl-C and Ctrl-V in SPFLite to do anything you wish.
These conventions still apply to any "control" or "dialog" or other GUI displayed by Windows itself, where keys like Ctrl-C and Ctrl-V mean what Windows says they mean, and nothing else.
There are a few basic keys that cannot be mapped. These are the Shift keys, the Windows keys (the ones with the "flag" on them), and the Caps Lock key. (However, the Windows Application key is fully mappable. In the picture below, the Application key is just to the left of the right Ctrl key. If you click on it, the name for the key will display as APPMENU.)
Some keys have only limited mapping, so that partial mapping is permitted, but not with all 8 possible combinations of Shift, Ctrl and Alt. These limited keys are Escape, Scroll Lock, Tab, and the Ctrl and Alt keys themselves. (Users of SPF-style editors on the PC will often map the right Ctrl key to (Enter) in SPFLite, since it simulates the Enter key on a 3270 terminal.) When you click on a key for which only partial mapping is available, the chord combinations you are not allowed to use will be grayed-out.
Some keys like Alt-Tab are reserved to swap between various Windows applications that are running at the same time. If SPFLite mapped this key, you'd never be able to Alt-Tab out of SPFLite to do something else. So, even if it were technically possible to "grab" these keys (which, in some cases, it is), it wouldn't be a good idea.
By the way, you should be aware that you can map the Pause key as well. Most software totally ignores this key. This might open up some useful possibilities for a command you used frequently and wanted to dedicate to a specific key.