diff --git a/CHANGELOG.md b/CHANGELOG.md index af410bf2..e6f4c03e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - widgets - 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 - 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 33517af1..5735b7c9 100644 --- a/src/client/app/widgets/inputs/keys.js +++ b/src/client/app/widgets/inputs/keys.js @@ -15,7 +15,7 @@ class Keys extends Widget { binding: {type: 'string|array', value: '', help: 'Key combo `string` or `array` of strings (see KeyboardJS documentation)'}, 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)', + '- `key`: pressed key name (usefull for handling multiple keys with a single keys widget, lowercased when referencing a character key)', '- `ctrl`: control key state', '- `alt`: alt key state', '- `shift`: shift key state', @@ -86,6 +86,10 @@ class Keys extends Widget { meta: e.metaKey } + if (context.key.length === 1) { + context.key = context.key.toLowerCase() + } + this.setValue(this.resolveProp('keydown', undefined, false, false, false, context), {sync: true, send: true}) } @@ -110,6 +114,10 @@ class Keys extends Widget { meta: e.metaKey } + if (context.key.length === 1) { + context.key = context.key.toLowerCase() + } + this.setValue(this.resolveProp('keyup', undefined, false, false, false, context), {sync: true, send: true}) }