forked from extern/Unexpected-Keyboard
Add custom layout documentation in doc/
(#643)
This commit is contained in:
parent
4906f8105f
commit
c9b6380ed0
110
doc/Custom-layouts.md
Normal file
110
doc/Custom-layouts.md
Normal file
@ -0,0 +1,110 @@
|
||||
# Custom layouts
|
||||
|
||||
Unexpected Keyboard allows custom layouts to be defined, loaded, and used in the app. These layouts are defined in XML.
|
||||
|
||||
## Existing keyboard layouts
|
||||
|
||||
The XML data files for the keyboard layouts that come with the app can be seen [in `/srcs/layouts`](https://github.com/Julow/Unexpected-Keyboard/tree/master/srcs/layouts).
|
||||
|
||||
## Structure
|
||||
|
||||
A complete keyboard file with a single row containing a single Turkish "i" key is provided below:
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keyboard name="Keyboard Name" script="latin">
|
||||
<modmap>
|
||||
<shift a="i" b="İ" />
|
||||
</modmap>
|
||||
<row>
|
||||
<key key0="i" />
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
Shift assignments can be changed on a per-character basis.
|
||||
|
||||
### Crash course to XML
|
||||
|
||||
An XML document is made out of tags.
|
||||
|
||||
Paired tags start with `<` and end with `>`, and must be closed by another tag that starts with `</`. They can have other tags as children. Paired tags used in Unexpected Keyboard include `<row>`...`</row>` and `<keyboard>`...`</keyboard>`.
|
||||
|
||||
Auto-terminating tags start with `<` and end with `/>`, and can't have any children. Auto-terminating tags used in Unexpected Keyboard include `<key />` and `<shift />`.
|
||||
|
||||
An XML tag can have attributes, defined using an equals sign and a pair of ASCII double quotes.
|
||||
|
||||
If you do not like XML, you can also use [this third-party GUI editor](https://unexpected-keyboard-layout-editor.lixquid.com/) to create or edit a keyboard layout.
|
||||
|
||||
### XML declaration
|
||||
|
||||
Every keyboard XML starts with `<?xml version="1.0" encoding="utf-8"?>`.
|
||||
|
||||
### Keyboard metadata
|
||||
|
||||
The `<keyboard>` tag encloses the whole keyboard. The following properties may be used:
|
||||
|
||||
* `name`: The name of the keyboard as it appears in the settings menu. If not present, it will just be called “Custom layout”.
|
||||
* `bottom_row`: Whether or not to show the common bottom row. Accepts `true` or `false`, and defaults to `true`.
|
||||
* `script`: The (main) writing system that it supports. Possible values are `arabic`, `armenian`, `bengali`, `cyrillic`, `devanagari`, `gujarati`, `hangul`, `hebrew`, `latin`, `persian`, `shavian`, and `urdu`. Defaults to `latin`.
|
||||
* `numpad_script`: The script to use for the numpad. This is useful for scripts where a different, non-ASCII set of numerals is used, like Devanagari and Arabic. Defaults to the same as `script`.
|
||||
|
||||
### Modmap
|
||||
|
||||
The `<modmap>` tag encloses custom mappings for the Shift and Fn key’s behavior.
|
||||
|
||||
Each entry contains two mandatory properties: `a` for the base character before the modifier is applied, and `b` for the modified character.
|
||||
|
||||
For example, to make the `I` key behave as in Turkish:
|
||||
|
||||
<modmap>
|
||||
<shift a="i" b="İ" />
|
||||
</modmap>
|
||||
|
||||
There can be as many of these tags inside `<modmap>` as needed.
|
||||
|
||||
### Row
|
||||
|
||||
The `<row>` tag encloses one row on the keyboard. It requires no properties, and supports the following:
|
||||
|
||||
* `height`: The height of the row. Defaults to 1, and accepts a positive floating point value.
|
||||
|
||||
The total height of the keyboard is defined in Settings as a percentage of the total height of the screen, which can be different between portrait and landscape. The height of a row is relative to the other ones, and are scaled to keep the height of the keyboard constant.
|
||||
|
||||
### Key
|
||||
|
||||
The `<key />` tag defines a key on the keyboard. It requires at least one of the following properties:
|
||||
|
||||
* `key0`: What the key should do when it is tapped.
|
||||
* `nw`, `ne`, `sw`, `se`, `w`, `e`, `n`, `s`: What the key should do when it is swiped. They are based on cardinal directions, and uses the convention that North is up. These are the new set of keywords, and should not be used with the other set of keywords.
|
||||
|
||||
nw | n | ne
|
||||
:-: | :--: | :-:
|
||||
w | key0 | e
|
||||
sw | s | se
|
||||
|
||||
* `key1` through `key8`: The older set of keywords for what the key should do when it is swiped. The directions are ordered as follows:
|
||||
|
||||
key1 | key7 | key2
|
||||
:--: | :--: | :--:
|
||||
key5 | key0 | key6
|
||||
key3 | key8 | key4
|
||||
|
||||
The following properties are optionally supported:
|
||||
|
||||
* `width`: The width of the key relative to the normal width. Defaults to `1` and accepts a positive floating point value.
|
||||
* `shift`: How much empty space to add to the left of this key. Defaults to `0` and accepts a non-negative floating point value.
|
||||
* `indication`: An extra label to show under the main label, intended to be used as a legend for 2A typing (e.g. `<key key0="2" indication="ABC" />`). Caution: if you have `key8` defined, it overlaps!
|
||||
* `slider`: If set to `true`, the keys `w` and `e` are sent repeatedly when the key is being slid on. Intended to be used on the space bar, and in fact used on the default space bar.
|
||||
|
||||
## Possible key values
|
||||
|
||||
`key0` and `nw` through `se` (`key1` through `key8`) take arbitrary strings of characters, and if they don't match any of the special values, it is printed verbatim. (This is intended behavior.)
|
||||
|
||||
Special values for the keys are documented in [this page](Possible-key-values).
|
||||
|
||||
### `loc ` prefix
|
||||
|
||||
Keys prefixed with `loc ` do not appear by default, and are only visible when they are enabled through the "Add keys to keyboard" option in the settings menu, or the language installed on the device is detected to require it.
|
||||
|
||||
## Portrait vs. landscape
|
||||
|
||||
Unexpected Keyboard remembers *separately* which layout has last been used in portrait and landscape orientation. That is to say, you may have one custom layout for portrait orientation, but another custom layout for landscape orientation, and Unexpected Keyboard will switch between them without your intervention.
|
145
doc/Possible-key-values.md
Normal file
145
doc/Possible-key-values.md
Normal file
@ -0,0 +1,145 @@
|
||||
# Key values
|
||||
|
||||
This is an exhaustive list of special values accepted for the `key0` through `key8` or `nw` through `se` attributes on a key. Any string that does not exactly match these will be printed verbatim.
|
||||
|
||||
## Escape codes
|
||||
Value | Escape code for
|
||||
:---- | :------
|
||||
`\?` | `?`
|
||||
`\#` | `#`
|
||||
`\@` | `@`
|
||||
`\n` | Literal newline character. This is different from `enter` and `action` in certain apps.
|
||||
`\t` | Literal tab character. This is different from `tab` in certain apps.
|
||||
`\\` | `\`
|
||||
|
||||
XML escape codes also work, including:
|
||||
|
||||
Value | Escape code for
|
||||
:------- | :------
|
||||
`&` | `&`
|
||||
`<` | `<`
|
||||
`>` | `>`
|
||||
`"` | `"`
|
||||
|
||||
## Modifiers
|
||||
System modifiers are sent to the app, which is free to do whatever they want in response.
|
||||
The other modifiers only exist within the keyboard.
|
||||
Value | Meaning
|
||||
:---------- | :------
|
||||
`shift` | System modifier.
|
||||
`ctrl` | System modifier.
|
||||
`alt` | System modifier.
|
||||
`meta` | System modifier. Equivalent to the Windows key.
|
||||
`fn` | Activates Fn mode, which assigns letters and symbols to special characters. e.g. `fn` `!` = `¡`
|
||||
`compose` | Compose key. Enables composing characters using Linux-like shortcuts; e.g. `Compose` `A` `single quote` types `Á` (A with acute accent).
|
||||
`capslock` | Actives and locks Shift
|
||||
|
||||
## Special keys
|
||||
These keys are sent to apps, which are free to ignore them. The keyboard do not perform editing in response to these keys.
|
||||
|
||||
`esc`, `enter`,
|
||||
`up`, `right`,
|
||||
`down`, `left`,
|
||||
`page_up`, `page_down`,
|
||||
`home`, `end`,
|
||||
`backspace`, `delete`,
|
||||
`insert`, `f1`-`f12`,
|
||||
`tab`, `copy`,
|
||||
`paste`, `cut`,
|
||||
`selectAll`, `pasteAsPlainText`,
|
||||
`undo`, `redo`
|
||||
|
||||
## Whitespace
|
||||
Value | Meaning
|
||||
:------ | :------
|
||||
`space` | Space bar.
|
||||
`nbsp` | No-break space. Note: To input the narrow no-break space recommended for French, use `\u202F`.
|
||||
`zwj` | Zero-width joiner.
|
||||
`zwnj` | Zero-width non-joiner.
|
||||
|
||||
## Keyboard editing actions
|
||||
These keys perform editing on the text without sending keys that the app can interpret differently or ignore.
|
||||
Value | Meaning
|
||||
:----------------- | :------
|
||||
`cursor_left` | Moves the cursor position to the left directly, without sending a `left` key event.
|
||||
`cursor_right` | Moves the cursor position to the right directly, without sending a `right` key event.
|
||||
|
||||
## Other modifiers and diacritics
|
||||
Value | Meaning
|
||||
:------------------- | :------
|
||||
`accent_aigu` | Acute accent. `á`
|
||||
`accent_caron` | Háček. `č`
|
||||
`accent_cedille` | Cedilla. `ç`
|
||||
`accent_circonflexe` | Circumflex. `â`
|
||||
`accent_grave` | Grave accent. `à`
|
||||
`accent_macron` | Macron. `ā`
|
||||
`accent_ring` | Ring accent. `å`
|
||||
`accent_tilde` | Tilde. `ã`
|
||||
`accent_trema` | Dieresis/umlaut. `ä`
|
||||
`accent_ogonek` | Ogonek. `ą`
|
||||
`accent_dot_above` | Dot accent. `ż` If applied to the lowercase `i`, removes the dot instead for Turkish. `ı`
|
||||
`accent_double_aigu` | Double acute accent. `ő`
|
||||
`accent_slash` | Slash through. `ø`
|
||||
`accent_arrow_right` | Right arrow above, used to denote a vector. `a⃗`
|
||||
`accent_breve` | Breve. `ă`
|
||||
`accent_bar` | Bar/strikethrough. `ᵢ`
|
||||
`accent_dot_below` | Dot below. `ạ`
|
||||
`accent_horn` | Horn accent. `ơ`
|
||||
`accent_hook_above` | Hook accent. `ả`
|
||||
`superscript` | Superscript. `ᵃ`
|
||||
`subscript` | Subscript. `ₐ`
|
||||
`ordinal` | Turns `a` and `o` into `ª` and `º`.
|
||||
`arrows` | Turns `1`-`4` and `6`-`9` into arrows.
|
||||
`box` | Turns `1`-`9`, `0`, and `.` into single-line, thin box-drawing characters.
|
||||
|
||||
## Bidirectional
|
||||
Value | Meaning
|
||||
:------ | :------
|
||||
`lrm` | Left-to-right mark.
|
||||
`rlm` | Right-to-left mark.
|
||||
`b(`, `b)`, `b[`, `b]`, `b{`, `b}`, `blt`, `bgt` | Sends the bracket characters, but with mirrored key legends for right-to-left languages. (`blt` and `bgt` print `<` and `>` respectively.)
|
||||
|
||||
## Hebrew
|
||||
Keys ending in `_placeholder` are normally hidden unless the Fn key is pressed.
|
||||
|
||||
`qamats`, `patah`,
|
||||
`sheva`, `dagesh`,
|
||||
`hiriq`, `segol`,
|
||||
`tsere`, `holam`,
|
||||
`qubuts`, `hataf_patah`,
|
||||
`hataf_qamats`, `hataf_segol`,
|
||||
`shindot`, `shindot_placeholder`,
|
||||
`sindot`, `sindot_placeholder`,
|
||||
`geresh`, `gershayim`,
|
||||
`maqaf`, `rafe`,
|
||||
`ole`, `ole_placeholder`,
|
||||
`meteg`, `meteg_placeholder`
|
||||
|
||||
## Unexpected Keyboard specific
|
||||
Value | Meaning
|
||||
:--------------------- | :------
|
||||
`config` | Gear icon; opens Unexpected Keyboard settings.
|
||||
`switch_text` | Switch to the text layer (main layer).
|
||||
`switch_numeric` | Switch to the numeric layer.
|
||||
`switch_emoji` | Switch to the emoji layer.
|
||||
`switch_back_emoji` | Switch to the text layer from the emoji layer.
|
||||
`switch_forward` | Change the keyboard layout, as long as Unexpected Keyboard has multiple keyboard layouts enabled in the settings.
|
||||
`switch_backward` | Change the keyboard layout to the previous one in the list.
|
||||
`switch_greekmath` | Switch to the Greek & Math Symbols layer.
|
||||
`change_method` | Open the input method picker dialog.
|
||||
`change_method_prev` | Switch to the previously used input method.
|
||||
`action` | Performs a special context-sensitive operation related to the Enter key. For example, in the Twitter (X) app, `enter` adds a new line, while `action` posts.
|
||||
`voice_typing` | Begin voice typing.
|
||||
`voice_typing_chooser` | Shows a menu where you can choose which voice typing provider to use, then begins voice typing when you make a selection.
|
||||
`shareText` | Emit a share Intent for the selected text. **Oddity:** This is in CamelCase.
|
||||
|
||||
## Unused
|
||||
These keys are known to do nothing.
|
||||
|
||||
`replaceText`, `textAssist`,
|
||||
`autofill`, `removed`
|
||||
|
||||
## Placeholders
|
||||
These keys are normally hidden unless the Fn modifier is activated.
|
||||
|
||||
`f11_placeholder` | `f12_placeholder`
|
Loading…
Reference in New Issue
Block a user