package virtual_dom

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

Module Vdom_keyboard.Keyboard_event_handlerSource

A Keyboard_event_handler.t is a collections of actions (commands and disabled keys) that can be used to handle keyboard events and to produce help text.

Sourcemodule Condition : sig ... end

A Condition.t is a condition based on a keyboard event (which importantly includes the event's focus). This is intended to be used in keyboard event handlers that look at the keyboard event to determine whether or not to take a certain action.

Sourcemodule Handler : sig ... end

A Handler.t handles a keyboard event by returning a unit Vdom.Effect.t. These should be used as building blocks for keyboard event handlers, for instance to handle a specific set of keys.

Sourcemodule Command : sig ... end
Sourcemodule Action : sig ... end
Sourcetype t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval empty : t
Sourceval of_action_list_exn : Action.t list -> t

of_action_list_exn and of_command_list_exn create a keyboard event handler from a list of actions. If the same key appears in multiple actions, an exception is raised.

Sourceval of_command_list_exn : Command.t list -> t
Sourceval add_action_exn : t -> Action.t -> t

add_action_exn adds a new action to a keyboard event handler. If any key from the new action already exists in the handler, an exception is raised.

Sourceval add_command_exn : t -> Command.t -> t

Like add_action_exn, but restricted to command actions

Sourceval add_disabled_key_exn : t -> Keystroke.t -> t

Like add_action_exn, but restricted to disabled key actions

Sourceval set_action : t -> Action.t -> t

Like add_action_exn, but overrides old actions in the case of a conflict.

Sourceval set_command : t -> Command.t -> t

Like set_action, but restricted to command actions

Sourceval set_disabled_key : t -> Keystroke.t -> t

Like set_action, but restricted to disabled key actions

Sourceval merge : on_dup:[ `Override_with_right | `Both | `Throw ] -> t -> t -> t

merge t1 t2 ~on_dup creates new keyboard event handlers containing the actions from t1 and t2. on_dup dictates how to deal with keys that have actions in both t1 and t2:

  • `Override_with_right uses the action from t2.
  • `Both uses both actions, and combines them into a single line if used with get_help_text. Note that if the actions belong to different groups in the help text, it will use the first group.
  • `Throw raises.
Sourceval handle_event : t -> Keyboard_event.t -> unit Virtual_dom.Vdom.Effect.t option
Sourceval handle_or_ignore_event : t -> Keyboard_event.t -> unit Virtual_dom.Vdom.Effect.t
Sourceval get_help_text : ?include_disabled_keys:unit -> t -> Help_text.t
Sourceval get_grouped_help_text : ?include_disabled_keys:unit -> ?custom_group_order:Vdom_keyboard__.Grouped_help_text.Group_name.t list -> t -> default_group:Vdom_keyboard__.Grouped_help_text.Group_name.t -> Grouped_help_text.t
Sourceval get_grouped_help_text_exn : ?include_disabled_keys:unit -> ?custom_group_order:Vdom_keyboard__.Grouped_help_text.Group_name.t list -> t -> Grouped_help_text.t
Sourceval get_action : t -> Keystroke.t -> Action.t option

Get the action associated with a keystroke in a keyboard event handler.

OCaml

Innovation. Community. Security.