[Home] [Purchase] [Download] [Manual] [Acknowledgements] [Sitemap] [Release Notes] [FAQ]

Up ] Swapping Caps Lock and Ctrl ] Disabling the WINDOWS key ] Mapping multimedia/web keys to numeric keypad ] Assigning characters to multimedia/web keys ] Multi-lingual English/French keyboard ] Multi-alphabet Serbian Cyrillic/Latin keyboard ] Tri-lingual Serbian Cyrillic / Latin / Greek keyboard ] Replacing AltGR with Kana ] French improved keyboard ] Multi-lingual Russian phonetic / US English keyboard ] Multi-lingual Bulgarian phonetic / US English keyboard ] Colemak keyboard ] Multi-lingual Hindi / US English keyboard ] Multi-lingual Hebrew / US English keyboard ] French multilingual keyboard ] Emulating Compose key using chained dead keys ] US English with all Latin accents using chained dead keys ] Mac Boot Camp: fixed positions of Alt, Windows and Ctrl keys ] Using NLS functions to simulate the "Context menu" key ] Using NLS functions to make Caps Lock and Alt Gr share the same key ] [ Using NLS functions to simulate togglable ROYA/LOYA modifier keys ] Sanskrit keyboard with Vedic extensions ]

Example - Using NLS functions to simulate togglable ROYA/LOYA modifier keys

Installer package: KbdEditInstallerSerbianLatinCyrillicAndGreekNlsRoyaLoya.exe

Layout file: Serbian Latin, Cyrillic and Greek NLS togglable Roya Loya.zip

Note: the example is based on an idea suggested by KbdEdit users Ari Adler and Miroslav Karkuš.

You can use the installer package to deploy this keyboard layout without any restrictions. Free Demo version can be used to make changes and test them. To deploy a modified version, a Premium, Personal or Lite edition is needed.

Modifier keys Roya and Loya are normally "non-togglable", i.e. their modifier combinations are active only as long as the key is held in the "pressed down" state. Various use cases, like building multi-lingual "switchable" keyboards, could benefit from these keys being "togglable", i.e. their modifier positions remaining active even after the user has released the key, like how the built-in Caps Lock and togglable Kana operate.

This example shows how the advanced NLS functions can be used to simulate Roya/Loya "togglability".

The theory

The "togglability" effect is achieved by setting up alternative key up NLS functions, which intercept the "key up" event of the Roya/Loya keys in a way that tricks the OS into thinking that the Roya (i.e. Loya) key has remained pressed down even after the physical key has been released.

The original key's "key up" event is not merely suppressed (the "No Event" alternative key up function). Instead, the "Send Param VK" function is used to send the "key up" event of the opposite Roya/Loya key. When Loya is pressed down, releasing it is sending the Roya "key up" event, and vice-versa. This achieves a double function of:

  • simulating Loya togglability (by not sending the matching Loya "key up" event), and
  • ensuring that the "competing" Roya key is turned off automatically as soon as Loya is activated (by sending the Roya "key up" instead).

This way, the user does not have to remember to turn Roya off manually before turning the Loya on.

To avoid the need for two dedicated physical Roya/Loya keys, their virtual codes are simulated as Ctrl-only functions of the Caps Lock and VK_OEM_7 keys:

  • Ctrl + Caps Lock turns Roya on (and also turns Loya off on the alternative key up event)
  • Ctrl + VK_OEM_7 turns Loya on (and also turns Roya off)

Note that a similar technique of overloading an existing key to perform an alternative Ctrl-only function is demonstrated in another example Using NLS functions to make Caps Lock and Alt Gr share the same key.

The Roya (i.e. Loya) key can be explicitely "un-toggled" via a Ctrl-only alternative NLS function of another two physical keys:

  • Ctrl + Left Win key turns Roya off
  • Ctrl + VK_OEM_MINUS turns Loya off

These combinations revert the layout to the "both Roya and Loya off" mode, in which the plain Base/Shift/AltGr modifier combinations are active.

Turning Roya on/off

Turning Loya on/off

Step by step instructions

The instructions show how to build an alternative version of an earlier example Tri-lingual Serbian Cyrillic / Latin / Greek keyboard.

The alternative "Serbian Cyrillic" and "Greek" layouts are mapped to the togglable ROYA and LOYA keys, unlike the original example, where they are mapped to the separate Caps Lock and togglable Kana positions.

The use of ROYA instead of Caps Lock has the benefit of allowing the Caps Lock to keep its original "Capital Letters" function, although unfortunately this works only for the BASE (Serbian Latin) position.

Another benefit is that the BASE positions remain available for the assignment of ligatures and dead keys, which is not possible with "separate Caps" mappings due to Caps Lock limitations.

Starting point

Start by opening the standard Serbian (Latin) layout (KLID 0000081A).

Enable the ROYA and LOYA modifier combinations

Switch to the Low-level editor.

Tick the LOYA checkbox to enable the "Loya" modifier key (KANA and ROYA checkboxes will be automatically ticked as well).

Enable the following modifier combinations, i.e. move them from "Unused modifier combinations" to "Active modifier combinations":

  • ROYA
  • SHIFT + ROYA
  • ROYA + ALTGR
  • LOYA
  • SHIFT + LOYA
  • LOYA + ALTGR

The "modifiers" section should now look like this:

Define special NLS functions for the ROYA key

Set the Caps Lock key's NLS functions to turn ROYA on on key down and turn LOYA off on key up:

  • Activate the Caps Lock key (VK_CAPITAL).
  • In the Special NLS functions dropdown, choose Advanced; this will open up the Special NLS functions editor dialog.
  • In the Ctrl dropdown, choose Send Param VK, then choose VK_OEM_FJ_ROYA in the dropdown that shows up next to it.
    This function enables turning the ROYA key on via the "Ctrl+Caps Lock down" combination.
  • In the Key down switches to alternative keyup functions column, tick the checkbox in the Ctrl row; a new column Alternative key up functions will show up, with eight dropdowns in it.
  • In each of the eight new dropdowns, choose Send Param VK, then choose VK_OEM_FJ_LOYA in the new dropdown that shows up next to it.
    This ensures that the LOYA key is consistently turned off when Caps Lock is released, whether Ctrl (or Shift/Alt) is down or not.

Next, set the Left Win key to turn ROYA off on key up:

  • Activate the Left Win key (VK_LWIN)
  • In the Special NLS functions dropdown, choose Advanced; this will open up the Special NLS functions editor dialog.
  • In the Ctrl dropdown, choose No Event
    This suppresses the original "Win key" function for the "Ctrl + Left Win" combination
  • In the Key down switches to alternative keyup functions column, tick the checkbox in the Ctrl row; a new column Alternative key up functions will show up, with eight dropdowns in it.
  • In each of the eight new dropdowns, choose Send Param VK, then choose VK_OEM_FJ_ROYA in the new dropdown that shows up next to it.
    This ensures that the ROYA key is consistently turned off when Left Win is released, whether Ctrl (or Shift/Alt) is down or not.

Define special NLS functions for the LOYA key

Set the VK_OEM_7 key's NLS functions to turn LOYA on on key down and turn ROYA off on key up:

  • Activate the VK_OEM_7 key (second one to the right from the L key).
  • Choose Advanced in the Special NLS functions dropdown.
  • In the Ctrl dropdown, choose Send Param VK, then choose VK_OEM_FJ_LOYA .
  • In the Key down switches to alternative keyup functions column, tick the checkbox in the Ctrl row.
  • In each of the eight new "Alternative key up functions" dropdowns, choose Send Param VK, then choose VK_OEM_FJ_ROYA.

Next, set the VK_OEM_MINUS key to turn LOYA off on key up:

  • Activate the VK_OEM_MINUS key (the key immediately to the left from the right Shift key)
  • Choose Advanced In the Special NLS functions dropdown.
  • In the Ctrl dropdown, choose No Event.
  • In the Key down switches to alternative keyup functions column, tick the checkbox in the Ctrl row.
  • In each of the eight new "Alternative key up functions" dropdowns, choose Send Param VK, then choose VK_OEM_FJ_L.

Copy the dead tables

Both the Serbian Cyrillic (KBDYCC.DLL 00000c1a) and Greek (KBDHE.DLL 00000408) layouts have dead tables of their own. These can be easily imported using the Dead-key editor's Import dead char from table command.

It is important to tick the Merge with current dead table radio button, which produces the desired end result of an amalgamation of all three layouts' dead tables.

The In case of merge conflict radio buttons can be left in either state, since the three dead tables are mergable without conflicts. The only semi-conflicting dead key is 00A8 ¨ , which appears as Diaresis in Serbian Latin, and Dialytika in Greek, but the two dead keys have disjoint sets of transformation pairs that neatly coexist in the new merged dead key.

Copy the "Serbian Cyrillic" and "Greek" layout mappings to the Roya/Loya positions

With the ROYA/LOYA switching and dead key groundwork laid out, it is now time to switch to the High-level editor and assign the two alternative layouts' mappings to ROYA and LOYA positions:

Source layout Source modifier position Target modifier position
Serbian Cyrillic
KBDYCC.DLL
00000c1a
Base Roya
Shift Shift+Roya
Ctrl not mapped
AltGR Roya+AltGR
Greek
KBDHE.DLL
00000408
Base Loya
Shift Shift+Loya
AltGR Loya+AltGR
Ctrl not mapped
Shift+Ctrl not mapped

Note that the original layouts' Ctrl positions are omitted, as they only contain rarely used ASCII control characters..

The easiest method for copying mappings from another layout is to open the "donor" layout in another KbdEdit instance and use it as a drag/drop source. All keys / modifier positions mappings can then be dragged one by one into the target instance - a little repetitive, but still easily doable in a few minutes. This technique is described in detail in an earlier example (Multi-lingual English / French keyboard using togglable KANA).

One important difference is that, in a ROYA/LOYA-based layout, all keys need to be copied this way, even those whose mappings are identical between the source and target layouts. The ROYA/LOYA keys don't have an equivalent of the KANALOK flag, so it is not possible to make them selectively affect only keys that genuinely need switching.

In practice, this means that it is also necessary to manually copy the mappings for the Space bar, the Tab, Escape, Backspace and Enter keys, as well as all of the numeric keypad keys.

Special attention should be paid to original layouts' dead keys - when dropping them into the target layout, Map as dead key should be chosen from the pop-up menu:

Manual index

Copyright © KbdSoft 2007-2024