keys: expose code name in keyup/keydown

This commit is contained in:
jean-emmanuel 2019-03-26 13:32:26 +01:00
parent 3b2c2e07d4
commit 43ccd7389d
2 changed files with 4 additions and 0 deletions

View file

@ -8,6 +8,7 @@
- switch: add `traversing` option (`true` by default)
- knob: act as a relative encoder when traversing gestures are enabled and `snap` is `false`
- keys: `key` variable in `keydown` and `keyup` is now always lowercased when referencing a single character
- keys; expose `code` variable from the keyboard event object (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code#Code_values)
- custom module
- expose shorthand functions `send` and `receives`
- expose a client object instead of just an id in `app` event handlers to allow retrieving the client's ip address as well

View file

@ -16,6 +16,7 @@ class Keys extends Widget {
keydown: {type: 'string', value: '', help: [
'This property is evaluated each time the key combo is pressed and defines the widget\'s own value. Formulas are given extras variables in this context:',
'- `key`: pressed key name (usefull for handling multiple keys with a single keys widget, lowercased when referencing a character key)',
'- `code`: pressed key code name (<a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code#Code_values" target="_blank">full list</a>)',
'- `ctrl`: control key state',
'- `alt`: alt key state',
'- `shift`: shift key state',
@ -80,6 +81,7 @@ class Keys extends Widget {
var context = {
key: e.key,
code: e.code,
ctrl: e.ctrlKey,
shift: e.shiftKey,
alt: e.altKey,
@ -108,6 +110,7 @@ class Keys extends Widget {
var context = {
key: e.key,
code: e.code,
ctrl: e.ctrlKey,
shift: e.shiftKey,
alt: e.altKey,