Skip to content

Commit

Permalink
Add test for AltGr abort on blur
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Aug 5, 2024
1 parent a020ef0 commit 06f14a5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test.keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,22 @@ describe('Key Event Handling', function () {
expect(kbd.onkeyevent).to.not.have.been.called;
});

it('should release ControlLeft on blur', function () {
const kbd = new Keyboard(document);
kbd.onkeyevent = sinon.spy();
kbd._handleKeyDown(keyevent('keydown', {code: 'ControlLeft', key: 'Control', location: 1}));
expect(kbd.onkeyevent).to.not.have.been.called;
kbd._allKeysUp();
expect(kbd.onkeyevent).to.have.been.calledTwice;
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, "ControlLeft", true);
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffe3, "ControlLeft", false);

// Check that the timer is properly dead
kbd.onkeyevent.resetHistory();
this.clock.tick(100);
expect(kbd.onkeyevent).to.not.have.been.called;
});

it('should generate AltGraph for quick Ctrl+Alt sequence', function () {
const kbd = new Keyboard(document);
kbd.onkeyevent = sinon.spy();
Expand Down

0 comments on commit 06f14a5

Please sign in to comment.