V1.Event
Event descriptions
All event descriptions contain the canvas
on which the event occured and the timestamp
indicating when the event occured.
Timestamps represent the time in microseconds, from an arbitrary starting point
Generic description of events occurring on canvases
type key =
| KeyEscape
| KeyF1
| KeyF2
| KeyF3
| KeyF4
| KeyF5
| KeyF6
| KeyF7
| KeyF8
| KeyF9
| KeyF10
| KeyF11
| KeyF12
| KeyPrintScreen
absent from Mac Keyboards
*)| KeyScrollLock
absent from Mac Keyboards
*)| KeyPause
absent from Mac Keyboards
*)| KeyGraveTilde
| Key1Exclamation
| Key2At
| Key3Number
| Key4Dollar
| Key5Percent
| Key6Caret
| Key7Ampersand
| Key8Asterisk
| Key9LParenthesis
| Key0RParenthesis
| KeyMinusUndersclre
| KeyEqualPlus
| KeyBackspace
| KeyTab
| KeyQ
| KeyW
| KeyE
| KeyR
| KeyT
| KeyY
| KeyU
| KeyI
| KeyO
| KeyP
| KeyLBracketCurly
| KeyRBracketCurly
| KeyBackslashPipe
replaced by KeyNonUSNumberTilde on ISO KB
*)| KeyCapsLock
| KeyA
| KeyS
| KeyD
| KeyF
| KeyG
| KeyH
| KeyJ
| KeyK
| KeyL
| KeySemicolonColon
| KeyQuoteDoublequote
| KeyNonUSNumberTilde
extra key left of Return on ISO KB, although generally mapped to KeyBackslashPipe instead
*)| KeyReturn
| KeyLShift
| KeyNonUSBackslashPipe
extra key right of LShift on ISO KB
*)| KeyZ
| KeyX
| KeyC
| KeyV
| KeyB
| KeyN
| KeyM
| KeyCommaLess
| KeyPeriodGreater
| KeySlashQuestion
| KeyRShift
| KeyLControl
| KeyLMeta
left Windows / Command key
*)| KeyLAlt
| KeySpacebar
| KeyRAlt
| KeyRMeta
right Windows / Command key
*)| KeyMenu
| KeyRControl
| KeyInsert
replaced by a Fn key on Mac (with a different code)
*)| KeyHome
| KeyPageUp
| KeyDeleteForward
| KeyEend
| KeyPageDown
| KeyUpArrow
| KeyLeftArrow
| KeyDownArrow
| KeyRightArrow
| KeyPadNumlockClear
on Mac, Clear replaces NumLock
*)| KeyPadEquals
on Mac keyboards only
*)| KeyPadDivide
| KeyPadMultiply
| KeyPadMinus
| KeyPad7Home
| KeyPad8UpArrow
| KeyPad9PageUp
| KeyPadPlus
| KeyPad4LeftArrow
| KeyPad5
| KeyPad6RightArrow
| KeyPadComma
specific to Brazilian keyboards
*)| KeyPad1End
| KeyPad2DownArrow
| KeyPad3PageDown
| KeyPad0Insert
| KeyPadDecimalDelete
| KeyPadEnter
| KeyF13
| KeyF14
| KeyF15
| KeyF16
| KeyF17
| KeyF18
| KeyF19
| KeyF20
| KeyF21
| KeyF22
| KeyF23
| KeyF24
| KeyInternational1
extra key left of RShift on JIS and Brazilian KB
*)| KeyInternational2
Katakana/Hiragana key right of Space on JIS KB
*)| KeyInternational3
extra key left of Backspace on JIS KB
*)| KeyInternational4
Henkan key right of Space on JIS KB
*)| KeyInternational5
Muhenkan key left of Space on JIS KB
*)| KeyInternational6
Kanma (comma) key right of KP0 on JIS KB
*)| KeyInternational7
Double-Byte/Single-Byte toggle key
*)| KeyInternational8
Undefined
*)| KeyInternational9
Undefined
*)| KeyLang1
Hangul/English toggle key (Korean)
*)| KeyLang2
Hanja conversion key (Korean)
*)| KeyLang3
Katakana key (Japanese)
*)| KeyLang4
Hiragana key (Japanese)
*)| KeyLand5
Zenkaku/Hankaku key (Japanese)
*)| KeyHelp
| KeyMute
| KeyVolumeUp
| KeyVolumeDown
A physical keyboard key, assuming an ideal "extended" QWERTY keyboard that synthetizes various layouts, including ANSI, ISO and JIS. Note that the symbol on the key may be different from the symbolic key name: this allows to refer to keys by their physical location, which can be useful for instance in games.
*)type flags = {
flag_shift : bool;
flag_alt : bool;
flag_control : bool;
flag_meta : bool;
flag_capslock : bool;
flag_numlock : bool;
flag_dead : bool;
}
The state of various keyboard flags
type key_data = {
key : key;
Physical key that was pressed/released
*)char : Stdlib.Uchar.t;
Equivalent Unicode character in the current layout
*)flags : flags;
State of various modifier keys when the event occured
*)}
Describes a keyboard event
val frame : unit canvas_event React.event
Occurs when the backend determines it is time to draw a new frame. A typical frequency is 60 times per second, though this varies depending on the platform.
val focus_in : unit canvas_event React.event
Occurs when the canvas becomes active as a result of being clicked or tabbed-into
val focus_out : unit canvas_event React.event
Occurs when the canvas becomes inactive as a result of another canvas being clicked or tabbed-into
val resize : size canvas_event React.event
Occurs when the canvas is resized by a user action
val move : position canvas_event React.event
Occurs when the canvas is moved by a user action
val close : unit canvas_event React.event
Occurs when the user clicks the close button
val key_down : key_data canvas_event React.event
Occurs when the user presses a key on the keyboard. The event description contains both the physical key (of type Event.key
and the Unicode character corresponding to that key (if any), according to the current keyboard layout. For instance, pressing the "A" key on an AZERTY keyboard will yield a physical key Event.KeyQ
and the Unicode code point for character "A".
val key_up : key_data canvas_event React.event
Occurs when the user releases a key on the keyboard
val button_down : button_data canvas_event React.event
Occurs when the user presses a mouse button
val button_up : button_data canvas_event React.event
Occurs when the user releases a mouse button
val mouse_move : size canvas_event React.event
Occurs when the user moves the mouse cursor
The timestamp of the last canvas event that occurred
val int_of_key : key -> int
int_of_key k
returns a platform-independent integer representation of key k
. This integer corresponds to the key code as defined by the USB standard for keybords.
val key_of_int : int -> key
key_of_int i
returns the key corresponding to the platform-independent integer i
in the range 0-255.
Exceptions:
Invalid_argument
if i
< 0 or i
> 255