package stk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Stk.KeySource

Utils for managing keys.

Sourceval key_is_mod : Tsdl.Sdl.keymod -> bool

key_is_mod k returns whether k is a modifier.

Sourcetype keystate = {
  1. key : Tsdl.Sdl.keycode;
  2. mask : Tsdl.Sdl.keymod;
  3. mods : Tsdl.Sdl.keymod;
  4. pred : Tsdl.Sdl.keymod -> bool;
}

A keyboard state corresponds to a key state if the specified key is pressed and the active modifiers after applying mask are equal to mods. mods is not used directly but instead a predicate is built to handle modifiers having left and right variants. mods is kept only for printing or storing purpose. mask is used to keep only modifiers of interest. For example not containing Sdl.Kmod.caps results in ignoring the state of Caps Lock when testing. Modifiers with left and right variants are not concerned by the mask since they are handled in the predicate.

Sourceval compare_keystate : keystate -> keystate -> int
Sourceval keystate_equal : keystate -> keystate -> bool
Sourceval pp_keystate : Format.formatter -> keystate -> unit
Sourceval set_default_keymask : Tsdl.Sdl.keymod -> unit

Set default mask used by keystate if no mask is specified in argument. Default is Tsdl.Sdl.Kmod.none. Sdl.Kmod.(reserved+mode).

Sourceval default_keymask : unit -> Tsdl.Sdl.keymod
Sourceval set_default_keymods : Tsdl.Sdl.keymod -> unit

Set default modifiers used by keystate if no modifier is specified in argument. Default is Sdl.Kmod.(reserved+mode).

Sourceval default_keymods : unit -> Tsdl.Sdl.keymod

Create a keystate from the given key. Optional parameters are:

  • mask to set the modifiers whose state will be ignored. If not specified, default_keymask is used.
  • mods to set the required modifiers. If not specified, default_keymods is used.
Sourceval match_keys : keystate -> key:Tsdl.Sdl.keycode -> kmod:Tsdl.Sdl.keymod -> bool

match_keys keystate ~key ~kmod returns true if the given key and modifier kmod maths the given keystate.

Sourceval keystate_of_string : string -> keystate
Sourceval string_of_mods : Tsdl.Sdl.keymod -> string
Sourceval string_of_keystate : keystate -> string
Sourceval keystate_ocf_wrapper : keystate Ocf.Wrapper.t
Sourceval keystate_list_ocf_wrapper : keystate list Ocf.Wrapper.t
Sourceval keystate_list_of_string : string -> keystate list
Sourceval string_of_keystate_list : keystate list -> string
Sourceval is_mod_pressed : Tsdl.Sdl.keymod -> bool
Sourceval shift_pressed : unit -> bool
Sourceval ctrl_pressed : unit -> bool
Sourceval css_keystate_parser : Css.T.ctx -> keystate Angstrom.t
OCaml

Innovation. Community. Security.