Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Keyboard layouts

Git² edited this page Nov 22, 2018 · 9 revisions

Keyboard layouts are .json files containing a list of keys to form the on-screen keyboard. You can quickly switch layouts by navigating to the userData/keyboards folder and clicking/tapping a layout file on the filesystem display, but you will need to edit your settings file to make any change permanent.

Keyboard layout codes

Keyboard layouts are identified by a code with the format language-REGION*, eg: en-US for American English.

A "valid" code is any provided layouts' filename (without the .json extension), and/or the name of any user-provided layout you might have copied in the userData/keyboards folder.


*In practice, this rule is not enforced.

Keyboard layout structure

The layout is organized by rows (see below). Each row contains an array of keys that will be parsed in order by keyboard.class.js, from left to right.

{
    "row_numbers": [],
    "row_1": [],
    "row_2": [],
    "row_3": [],
    "row_space": []
}

Each key contains name and cmd properties, and sometimes prefixed name and cmd properties. Valid prefixes are:

  1. fn_
  2. altshift_
  3. alt_
  4. ctrl_
  5. shift_

shift_ is the "less important" prefix, and fn_ the "most important".

When a special key (Shift,Control,Alt...) is in use, the matching prefixed cmd property will be used. If multiple special keys are active and the key has multiple matching prefixed properties, the "most important" one will be used.

There is also and additional prefix capslck_ that will replace the shift_ property if the shift command is locked (caps-lock). It is mostly used to allow typing uppercase diacritics like "É".

Prefixed or not, name is the text to display on the key, and cmd is the sequence to send to the shell.

Since sequences for special keys like delete, enter, or control+A are invalid JSON characters, special ~~~CTRLSEQx~~~ sequences (where x is an integer from 1 to 21) are used instead. They are replaced by the correct UTF8 character by the parser. The list of all CTRLSEQ characters is on the fifth line of keyboard.class.js. You might need a special text editor to see them correctly.

Another type of parsed sequences are ESCAPED|-- commands. They are not forwarded to the shell and instead trigger special actions on the keyboard, eg: ESCAPED|-- SHIFT: LEFT.

Here is a key example:

{
    "name": "r",
    "cmd": "r",
    "shift_name": "R",
    "shift_cmd": "R",
    "ctrl_cmd": "~~~CTRLSEQ8~~~",
    "alt_cmd": "~~~CTRLSEQ1~~~r"
}

About latin diacritics

To write special latin characters such as "ô" or "Ë", the keyboard parser understand the following escape sequences:

  • ESCAPED|-- CIRCUM
  • ESCAPED|-- TREMA

When triggered, the next character will be converted to its diacritic variant (if there is one). Currently support for diacritics is limited to what's useful to the French keyboard.

Clone this wiki locally