bind: Key bindings

View source: R/bindings.R

bindR Documentation

Key bindings

Description

bind() maps a key (or several keys separated by commas) to an action. Bindings can be attached to the app (app()), to the screen, to a widget type (widget()) or to a single widget (widget$bind()). When a key is pressed, bindings are searched from the focused widget up to the app, so the most local binding wins.

Usage

bind(key, action, description = NULL)

Arguments

key

Key name such as "q", "ctrl+c", "shift+tab", "f1", or several keys: "q,escape".

action

Action name or a function. Functions bound on the app are called as action(app); functions bound on a widget as action(widget, app).

description

Optional human readable description (for help screens and footers).

Details

An action is either the name of an action or a function. Named actions are looked up on the widget that owns the binding, then on its ancestors, then on the app. Prefix a name with "app." to call an app action directly. Built-in app actions are "quit", "focus_next", "focus_previous" and "refresh".

Value

An object of class termr_binding.

Examples

bind("q", "quit")
bind("ctrl+r", function(app) app$refresh(), "Redraw")

termr documentation built on Oct. 21, 2026, 5:13 p.m.