From 43ccd7389d3414a8d8bdd90d52eed07a84be0198 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 26 Mar 2019 13:32:26 +0100 Subject: [PATCH] keys: expose `code` name in keyup/keydown --- CHANGELOG.md | 1 + src/client/app/widgets/inputs/keys.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6f4c03e..9f3f8041 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/client/app/widgets/inputs/keys.js b/src/client/app/widgets/inputs/keys.js index 5735b7c9..5a15a4e8 100644 --- a/src/client/app/widgets/inputs/keys.js +++ b/src/client/app/widgets/inputs/keys.js @@ -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 (full list)', '- `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,