Skip to content

Commit

Permalink
adding listner to up/dwon arrow for battery %, in order to increase/d…
Browse files Browse the repository at this point in the history
…recrease value with keyboard
  • Loading branch information
jparez committed Jan 27, 2025
1 parent a405404 commit 32f8701
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/Battery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 32f8701

Please sign in to comment.