This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

KeyboardWidget

 9th October 2021 at 12:12pm

Introduction

The keyboard widget allows ActionWidgets to be triggered by specific key combinations. There is also a shorthand for generating Messages via the message and param attributes.

Content and Attributes

The content of the <$keyboard> widget is rendered normally. The keyboard shortcuts only take effect when the focus is within the contained content.

AttributeDescription
actionsA string containing ActionWidgets to be triggered when the key combination is detected
New in: 5.2.0 The variables: event-key, event-code and modifier are available for the actions
messageThe title of the WidgetMessage to generate
paramThe parameter to be passed with the WidgetMessage
keyKey string identifying the key(s) to be trapped (see below)
classA CSS class to be assigned to the generated HTML DIV element
tag New in: 5.1.14 The html element the widget creates to capture the keyboard event, defaults to:
» span when parsed in inline-mode
» div when parsed in block-mode

Variables

New in: 5.2.0 The following variables are made available to the actions:

VariablesDescription
event-keyThe event-key variable contains the character, if possible. eg: 1. You can experiment with some settings at: Key Codes (Example)
event-codeThe event-code variable contains a character description. eg: Digit1 instead of 1. Or Space instead of an empty string , which is hard to see
event-key-descriptorThe event-key-descriptor variable is available if the keyboard event captured was configured using a keyboard shortcut descriptor of the form ((my-shortcut)) which references a configuration tiddler.
modifierThe modifier Variable contains the Modifier Key held during the event (can be normal, ctrl, shift, alt or combinations thereof)

Key Strings

Key strings are made up of one or more key specifiers separated by spaces. Each key specifier is zero or more of the modifiers alt, shift, ctrl or meta followed by the name of a key, all joined with "+" plus or "-" minus symbols. Key names are either the letter or digit printed on the key (eg "a" or "1"), or one of the special keys backspace, tab, enter or escape.

ctrlshiftaltmeta+-+backspace<a-z,0-9>tabenterescape

For example:

A
shift+A
shift+escape
ctrl+enter
ctrl+shift+alt+A

More Info