From dd1c04acbf708111cee32a49f11663d779039581 Mon Sep 17 00:00:00 2001 From: Lucas Kellner Date: Sat, 27 Apr 2019 13:41:12 -0400 Subject: [PATCH] numbercontrollerbox to respond to arrow inputs --- src/dat/controllers/NumberControllerBox.js | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/dat/controllers/NumberControllerBox.js b/src/dat/controllers/NumberControllerBox.js index 462ebf2..4c53f1b 100644 --- a/src/dat/controllers/NumberControllerBox.js +++ b/src/dat/controllers/NumberControllerBox.js @@ -93,12 +93,30 @@ class NumberControllerBox extends NumberController { dom.bind(this.__input, 'blur', onBlur); dom.bind(this.__input, 'mousedown', onMouseDown); dom.bind(this.__input, 'keydown', function(e) { - // When pressing enter, you can be as precise as you want. - if (e.keyCode === 13) { - _this.__truncationSuspended = true; - this.blur(); - _this.__truncationSuspended = false; - onFinish(); + switch (e.key) { + case 'Enter': + { + // When pressing enter, you can be as precise as you want. + _this.__truncationSuspended = true; + this.blur(); + _this.__truncationSuspended = false; + onFinish(); + break; + } + case 'ArrowUp': + { + _this.setValue(_this.getValue() + _this.__impliedStep) + break; + } + case 'ArrowDown': + { + _this.setValue(_this.getValue() - _this.__impliedStep) + break; + } + default: + { + break; + } } });