1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 10:37:20 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/widgets/KeyboardWidget.tid

60 lines
2.9 KiB
Plaintext
Raw Normal View History

2015-05-14 09:16:29 +00:00
caption: keyboard
2014-03-02 19:30:13 +00:00
created: 20140302192136805
modified: 20211009121239821
tags: Widgets TriggeringWidgets
2014-03-02 19:30:13 +00:00
title: KeyboardWidget
type: text/vnd.tiddlywiki
! 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.
2014-03-02 19:30:13 +00:00
! 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.
2014-03-02 19:30:13 +00:00
|!Attribute |!Description |
2021-05-25 21:18:37 +00:00
|actions |A string containing ActionWidgets to be triggered when the key combination is detected<br><<.from-version "5.2.0">> The variables: ''event-key'', ''event-code'' and ''modifier'' are available for the actions |
2014-10-10 20:06:48 +00:00
|message |The title of the [[WidgetMessage|Messages]] to generate |
|param |The parameter to be passed with the [[WidgetMessage|Messages]] |
|key |Key string identifying the key(s) to be trapped (see below) |
2014-03-02 19:30:13 +00:00
|class |A CSS class to be assigned to the generated HTML DIV element |
|tag|<<.from-version "5.1.14">> The html element the widget creates to capture the keyboard event, defaults to:<br>» `span` when parsed in inline-mode<br>» `div` when parsed in block-mode|
2014-03-02 19:30:13 +00:00
2021-05-25 21:18:37 +00:00
! Variables
<<.from-version "5.2.0">> The following variables are made available to the actions:
|!Variables |!Description |
|`event-key` |The <<.var event-key>> variable contains the character, if possible. eg: `1`. You can experiment with some settings at: [[Key Codes (Example)]] |
|`event-code` |The <<.var 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-descriptor` |The <<.var event-key-descriptor>> variable is available if the keyboard event captured was configured using a [[keyboard shortcut descriptor|Keyboard Shortcut Descriptor]] of the form `((my-shortcut))` which references a configuration tiddler. |
2021-05-25 21:18:37 +00:00
|`modifier` |The [[modifier Variable]] contains the Modifier Key held during the event (can be <kbd>normal</kbd>, <kbd>ctrl</kbd>, <kbd>shift</kbd>, <kbd>alt</kbd> or combinations thereof) |
2014-03-02 19:30:13 +00:00
! 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 <kbd>alt</kbd>, <kbd>shift</kbd>, <kbd>ctrl</kbd> or <kbd>meta</kbd> 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 <kbd>backspace</kbd>, <kbd>tab</kbd>, <kbd>enter</kbd> or <kbd>escape</kbd>.
2014-03-02 19:30:13 +00:00
<$railroad text="""
[: {
("alt" | "shift" | "ctrl" |: "meta" ) +("+" | "-")
}
"+"
]
( "<a-z,0-9>" | "backspace" |: "tab" | "enter" | "escape" )
"""/>
2014-03-02 19:30:13 +00:00
For example:
```
A
shift+A
shift+escape
ctrl+enter
ctrl+shift+alt+A
```
2021-05-25 21:18:37 +00:00
! More Info
<<list-links "[tag[KeyboardWidget]]">>