KeyLayout
final class KeyLayout
Package: dev.joid.lib.input.key · Module: core · Source: KeyLayout.java
Translates the place of a letter or punctuation key into the key that the keyboard layout of the user types there.
Description
Section titled “Description”A window library reports a key by its place on a US QWERTY keyboard: on a French AZERTY keyboard, the key that types a arrives as Key.Q.
The input forwarder of a backend gives each key press two keys, its place and the key that the layout names (Input forwarding); a KeyLayout computes the second from the first.
Only the letters A to Z and the punctuation keys from Key.APOSTROPHE to Key.GRAVE_ACCENT depend on the layout; every other key passes through unchanged.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
KeyLayout | from(Function<Key,String> nameFunction) factory | Creates a layout from a function that returns the text that a place of the keyboard types with the current layout, such as the key name of the window library. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
Key | translate(Key key) | Returns the key that the layout types at a place. |
Key | fromCharacter(char character) static | Returns the letter or punctuation key that types a character, whatever its case, or null for any other character. |
boolean | isLayoutKey(Key key) static | If true, the key depends on the layout: a letter or a punctuation key. |
Creation details
Section titled “Creation details”KeyLayout from(Function<Key,String> nameFunction) factory
Creates a layout from a function that returns the text that a place of the keyboard types with the current layout, such as the key name of the window library.
The function may return null when the place types nothing.
Method details
Section titled “Method details”translate
Section titled “translate”Key translate(Key key)
Returns the key that the layout types at a place. The place comes back unchanged when it does not depend on the layout, or when the name function does not give one character that JOID knows.
fromCharacter
Section titled “fromCharacter”Key fromCharacter(char character) static
Returns the letter or punctuation key that types a character, whatever its case, or null for any other character.
isLayoutKey
Section titled “isLayoutKey”boolean isLayoutKey(Key key) static
If true, the key depends on the layout: a letter or a punctuation key.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
