From 9b25e7ef0e87e168ec12b43834b5c74cf6ad68c7 Mon Sep 17 00:00:00 2001 From: Dmytro Bartieniev Date: Wed, 25 Nov 2020 16:59:59 +0200 Subject: [PATCH] Add keydown event to handle up and down arrows keypress events --- src/domain_abstract/ui/InputNumber.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/domain_abstract/ui/InputNumber.js b/src/domain_abstract/ui/InputNumber.js index 4a2c13a5e3..fb54de536d 100644 --- a/src/domain_abstract/ui/InputNumber.js +++ b/src/domain_abstract/ui/InputNumber.js @@ -11,7 +11,8 @@ export default Input.extend({ 'change select': 'handleUnitChange', 'click [data-arrow-up]': 'upArrowClick', 'click [data-arrow-down]': 'downArrowClick', - 'mousedown [data-arrows]': 'downIncrement' + 'mousedown [data-arrows]': 'downIncrement', + keydown: 'handleKeyDown' }, template() { @@ -81,6 +82,21 @@ export default Input.extend({ this.elementUpdated(); }, + /** + * Handled when user uses keyboard + */ + handleKeyDown(e) { + if (e.key === 'ArrowUp') { + e.preventDefault(); + this.upArrowClick(); + } + + if (e.key === 'ArrowDown') { + e.preventDefault(); + this.downArrowClick(); + } + }, + /** * Fired when the element of the property is updated */