Module Brr_note_kit.Key
User keyboard.
Physical keys
Note. Physical keys are for using the keyboard as a controller. Do not use them to derive text input, they are unrelated to the user's keyboard layout for text entry. Use input events for text entry.
type t
=[
|
`Alt of [ `Left | `Right ]
|
`Arrow of [ `Up | `Down | `Left | `Right ]
|
`Ascii of Stdlib.Char.t
|
`Backspace
|
`Ctrl of [ `Left | `Right ]
|
`End
|
`Enter
|
`Escape
|
`Func of int
|
`Home
|
`Insert
|
`Key of code
|
`Meta of [ `Left | `Right ]
|
`Page of [ `Up | `Down ]
|
`Return
|
`Shift of [ `Left | `Right ]
|
`Spacebar
|
`Tab
]
The type for physical keys.
Warning. This type is overdefined for now. For example except for
`Shift
,`Ctrl
andAlt
,`Left
and`Right
modifiers cannot be distinguished;`Left
is always returned.`Enter
and`Return
cannot be distinguished,`Return
is always returned.
val of_ev : Brr.Ev.Keyboard.t Brr.Ev.t -> t
of_ev e
is the physical key of the keyboard evente
.
Keyboard events
val on_target : ?capture:bool -> ?propagate:bool -> ?default:bool -> Brr.Ev.target -> events
on_target t
is keyboard events for targett
. The other parameters are those ofBrr_note.Evr.on_target
.
Key events
val any_holds : events -> bool Note.signal
any_holds evs
istrue
whenever any key is down.
Modifiers signals
val alt : events -> bool Note.signal
alt evs
istrue
whenver an alt key is down on the target. Equivalent to:S.Bool.(holds evs (`Alt `Left) || holds evs (`Alt `Right))
val ctrl : events -> bool Note.signal
ctrl evs
istrue
whenver an ctrl key is down on the target. Equivalent to:S.Bool.(holds evs (`Ctrl `Left) || holds evs (`Ctrl `Right))
val meta : events -> bool Note.signal
meta evs
istrue
whenver an meta key is down on the target. Equivalent to:S.Bool.(holds evs (`Meta `Left) || holds evs (`Meta `Right))
val shift : events -> bool Note.signal
shift evs
istrue
whenver an shift key is down on the target. Equivalent to:S.Bool.(holds evs (`Meta `Left) || holds evs (`Meta `Right))
Semantic incoherences
holds
and any_holds
may be initially set to false
even though they should be true
if for_target
is invoked when the corresponding keys are depressed.
Key repeat events
Key repeat events are not exposed. There are two main use cases for key repeat. First during text input, but his should be handled by text input events and is out of scope. Second for controlling changes to a variable over time, e.g. scrolling with a keyboard. In the latter case it is better to create a timing signal or event with a known rate while the key is held.