Special NLS Functions
The special NLS functions are present in certain Far Eastern (FE) keyboards, which generally function in conjunction with a special IME (Input Method Editor) application for the entry of complex ideographic characters. These functions are assigned to individual virtual key codes (VKs) in combination with a specific combination of the Shift, Ctrl and Alt modifier keys. Any such combination overrides the usual Unicode character-producing functions that may be otherwise defined for the same VK / modifier position.
Since version 19.5.0, KbdEdit's Low-level editor fully supports editing of all available NLS functions. This, as will be shown shortly, can provide useful customisations even to non-FE layouts.
NLS functions in the UI
Keys with NLS functions are visually denoted by a small red mark in the upper right corner:
The "Special NLS functions" dropdown indicates the type of NLS function for the current key: None, Alternative VK code or Advanced.
The "Alternative VK code" function allows the key to produce a different VK code for the chosen combinations of the Shift, Ctrl and Alt modifier keys. Activating this function changes the UI to reveal additional two widgets:
A non-empty choice has to be made in both widgets for the "Alternative VK code" function to "stick". Leaving the dropdown empty and/or clearing all check-boxes has the same effect as reverting the Special NLS functions dropdown to None.
The alternative VK codes function is useful for laptops and other keyboards with a limited number of physical keys. It allows the missing keys to be simulated via an unused modifier combination of another key. This example shows how to simulate a missing VK_APPS (ie "context menu") key.
The function can also be used to suppress or modify the function of a standard key. A good example is Caps Lock, which is often pressed by accident. By using Alternative VK codes, Caps Lock can instead be assigned to a multi-key combination, reducing the incidence of its accidental activation. An added bonus is that the "plain" position remains free for other uses. This example shows how the "plain" Caps Lock can be used as a general-purpose Kana modifier key, while still retaining the "Caps Lock" function in conjunction with Ctrl.
Note that the "Alternative VK code" function is merely a special combination of the more general advanced NLS functions settings, relying on the "param VK" NLS function type. You can easily reveal the lower level settings used to emulate an "alternative VK" by switching to the Special NLS functions dialog.
Keys simulated via the Alternative VK code function have a few limitations over the use of plain, "unmutable" keys.
Shift, Ctrl and Alt cannot be modified/produced
The Shift, Ctrl and Alt VK codes are reserved for the modifier function, and hence cannot be modified nor produced as an "alternative" VK.
The "down" state of Shift, Ctrl and/or Alt cannot be suppressed
It is not possible to suppress the "down" state of the Shift/Ctrl/Alt modifiers used to trigger the alternative VK. If you have defined Ctrl + <base VK> to produce an <alternative VK>, the latter will always be seen as Ctrl + <alternative VK>, rather than <alternative VK> alone.
Depending on the alternative VK simulated, this may or may not be an issue. When simulating the VK_APPS key ("context menu", see the example), the fact that the Ctrl key is down is immaterial, because both Ctrl+VK_APPS and VK_APPS have the same effect - displaying the context menu.
The "Caps Lock" function is similarly unaffected by the state of Shift/Ctrl/Alt.
On the other hand, cursor movement keys (Home/End/arrows), function keys and letter-producing keys are usually quite sensitive to the state of Shift/Ctrl/Alt. In most text editors, VK_HOME alone moves the cursor to the beginning of the line, while Shift-VK_HOME selects text between the cursor and the beginning of the line, and Ctrl+VK_HOME goes to the beginning of the file. Keys like this are generally not good candidates for alternative VKs.
The original VK can accidentally remain stuck in the "down" state
Taking this example, which assigns Caps Lock as an alternative VK to Ctrl+Kana, this sequence will result in a stuck Kana key:
This happens because pressing the Ctrl down (step 2) temporarily turns Kana into Caps Lock, causing the step 3 to be interpreted as releasing Caps Lock instead of Kana. Without a matching "key up" event, the OS continues to see Kana as being in the "down" state, until it is re-synced by a clean key down/up sequence.
In most cases, this is just a harmless artifact, and the stuck base key can be easily "unstuck" by simply pressing/releasing it alone. Accidental sticking can be easily avoided by being disciplined about the order of key presses/releases, ie ensuring that the Ctrl/Shift/Alt modifiers are always first to be pressed, and last to be released.
The NLS functions are capable of even more complex customisations, which are accessed by choosing "Advanced" in the "Special NLS functions" dropdown or, alternatively, choosing "NLS functions" in the context menu:
This opens up the Special NLS functions dialog, in which the key's NLS functions can be tuned at a much finer level of detail.
For keys with advanced NLS functions, a detailed summary of all NLS functions is shown in a separate window:
Most of the advanced NLS functions are highly specific to the narrow domain of Far Eastern IME layouts. more specifically the Japanese and Korean layouts.
System layouts with NLS functions
A standard Windows installation contains several layout DLL files with special NLS functions. All these layouts target two FE languages: Japanese and Korean:
These layouts offer some clues as to how the NLS functions are used internally to support the FE-specific functions. As an example, system layout KBDJPN.DLL (00000411 Japanese (Japan)) has special NLS functions defined for virtual keys VK_CAPITAL (Caps Lock) and VK_OEM_3 ( ` inverted quotation mark):
Some of these functions rely on the "param VK" NLS function, which causes the original key to "mutate" into a different VK code for the chosen modifier combination - this same functionality is used to implement KbdEdit's alternative VK code feature.
Thanks to this function, the Japanese keyboard can toggle the KANA state for KANALOK mappings using Shift+Ctrl+CapsLock, which has the same effect as if VK_KANA was mapped to a hypothetical physical key of its own. Likewise, Alt+VK_OEM_3 produces the VK_KANJI code, removing the need for a dedicated Kanji key.
As mentioned above, the Shift / Ctrl / Alt combinations controlling the NLS functions are not restricted to the active modifier combinations. This is why NLS functions such as Alt+VK_CAPITAL (Katakana) and Alt+VK_OEM_3 (VK_KANJI) are possible, even though Alt alone is not an active (nor valid) high-level modifier combination.
Of the 16 Japanese/Korean layout DLL files listed above, only two are actually registered in the Windows list of installed layouts : KBDJPN.DLL (registered as 00000411 "Japanese") and KBDKOR.DLL (00000412 "Korean").
The remaining layout files are activated in a special indirect way: instead of being referenced directly by a unique KLID, they are selected and loaded through a rather convoluted and poorly documented process, which depends on certain registry values under HKLM\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters. These two blog posts have more details:
This special way of registering layout DLL files is currently not supported by KbdEdit, although there are plans to support it eventually.
To make any of these "shadow" DLL files visible to KbdEdit, you first have to import them via Register Layout DLL file, so that they are given a proper KLID of their own (note that this still won't allow you to edit the unsupported NEC/Fujitsu layout files kbdnec*.dll and f3ahvoas.dll).
Also note that, even though KbdEdit allows you to register any layout DLL under the Japanese or Korean locale, including modified versions of the manually registered "shadow" DLL files, they are unlikely to function properly with the Japanese/Korean IMEs. This is because they lack the special registration under HKLM\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters, as described in the above blog posts.
However, you may still be able to register your custom Japanese/Korean layout DLL files manually, by editting string values "LayerDriver JPN" and "LayerDriver KOR":
Copyright © KbdSoft 2007-2021