diff --git a/lib/Input.js b/lib/Input.js index 2ea8823cad6..b022410bbcf 100644 --- a/lib/Input.js +++ b/lib/Input.js @@ -133,7 +133,7 @@ class Keyboard { const description = this._keyDescriptionForString(key); this._modifiers &= ~this._modifierBit(description.key); - this._pressedKeys.delete(description.key); + this._pressedKeys.delete(description.code); await this._client.send('Input.dispatchKeyEvent', { type: 'keyUp', modifiers: this._modifiers, diff --git a/test/test.js b/test/test.js index 750ed1c96e0..83af6515836 100644 --- a/test/test.js +++ b/test/test.js @@ -2350,6 +2350,18 @@ describe('Page', function() { await page.keyboard.type('Hello World!'); expect(await page.evaluate(() => textarea.value)).toBe('He Wrd!'); }); + it('should remove keys from _pressedKeys after keyboard.up()', async({page, server}) => { + await page.goto(server.PREFIX + '/input/textarea.html'); + await page.focus('textarea'); + await page.keyboard.down('w'); + expect(await page.keyboard._pressedKeys.size).toEqual(1); + await page.keyboard.down('1'); + expect(await page.keyboard._pressedKeys.size).toEqual(2); + await page.keyboard.up('w'); + expect(await page.keyboard._pressedKeys.size).toEqual(1); + await page.keyboard.up('1'); + expect(await page.keyboard._pressedKeys.size).toEqual(0); + }); it('keyboard.modifiers()', async({page, server}) => { const keyboard = page.keyboard; expect(keyboard._modifiers).toBe(0);