These events and signals should only be used for treating keys as
actuators. For getting textual input use the support in the
`Jsoo backend consult the important
information about key handling.
Useri_jsoo.Key has important information about key handling
Note about the absence of key repeat events.
[ `Alt of [ `Left | `Right ]
| `Arrow of [ `Down | `Left | `Right | `Up ]
| `Ctrl of [ `Left | `Right ]
| `Digit of int
| `Function of int
| `Meta of [ `Left | `Right ]
| `Page of [ `Down | `Up ]
| `Shift of [ `Left | `Right ]
| `Uchar of int
| `Unknown of int ]
A key identifier corresponds to a physical key on a given
keyboard. It is not related to the textual character that will
be inserted by depressing that key. Use
Useri.Text events for getting
textual data inserted by a user.
val uchar :
char -> [> `Uchar of int ]
uchar cis a key identifier from
val pp_id :
Format.formatter -> id -> unit
pp_id ppf idprints an unspecified representation of
Some of the signals below have caveats to consider in very
improbable corner cases, see note on semantics.
val any_down :
any_downoccurs whenever a key goes down.
val any_up :
any_upoccurs whenever a key goes up.
val any_holds :
truewhenever any key is down.
val down :
id -> unit React.event
down idoccurs whenever the key
val up :
id -> unit React.event
up idoccurs whenever the key
val holds :
id -> bool React.signal
truewhenever the key
val alt :
truewhenever an alt key is down. Equivalent to:
S.Bool.(holds (`Alt `Left) || holds (`Right `Right))
val ctrl :
truewhenever a ctrl key is down. Equivalent to:
S.Bool.(holds (`Ctrl `Left) || holds (`Ctrl `Right))
val meta :
truewhenever a meta key is down. Equivalent to:
S.Bool.(holds (`Meta `Left) || holds (`Meta `Right))
val shift :
truewhenever a shift key is down. Equivalent to:
S.Bool.(holds (`Shift `Left) || holds (`Shift `Right))
If keys are hold by the user during initialisation of
Useri.Key.holds may initially wrongly be
until corresponding keys are released.
Useri.Key.holds may not be accurate the first time
they are created inside a
React update cycle in which they
should occur or update themselves. Note that this is quite
unlikely, the only case where this can occur is if these
functions are called as a dependency of the
events or signals.
Useri doesn't expose key repeat events. There are two main use
cases for key repeat. First during text input, this is handled
Useri.Text events. Second, for controlling changes to a variable
over time (e.g. scrolling with the keyboard). In the latter case
it is better to use a function over a
signal until the key is up.