From 3d1a08893e5e89648b41ee57cfaf7cc04b2ad23a Mon Sep 17 00:00:00 2001 From: jparez Date: Thu, 23 Jan 2025 16:04:09 +0100 Subject: [PATCH] adding listner to up/dwon arrow for battery %, in order to increase/drecrease value with keyboard --- src/plugins/Battery.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugins/Battery.js b/src/plugins/Battery.js index 8ec0b92..730c34d 100644 --- a/src/plugins/Battery.js +++ b/src/plugins/Battery.js @@ -194,6 +194,17 @@ module.exports = class Battery extends OverlayPlugin { }, }); + // bind arrow keys to input, to increase/decrease value with arrow up/down + this.instance.addListener(this.chargeInput.element, 'keydown', (e) => { + if (e.key === 'ArrowUp') { + e.preventDefault(); + this.chargeInput.setValue(Math.min(100, Number(this.chargeInput.getValue()) + 1), true); + } else if (e.key === 'ArrowDown') { + e.preventDefault(); + this.chargeInput.setValue(Math.max(0, Number(this.chargeInput.getValue()) - 1), true); + } + }); + this.chargeInput.element.className = 'gm-charge-input'; this.chargeGroup.appendChild(this.chargeInput.element);