mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(keyboard): make keyboard.down generate input event by default (#1016)
This patch starts generating input events for `keyboard.down`, addressing bullet 2 of #723. With this patch, there's no longer any difference between `keboard.press('a')` and `keyboard.press('a', {text: 'a'})`. BREAKING CHANGE: `keyboard.down('a')` starts generating input event (wasn't the case before). References #723
This commit is contained in:
committed by
Andrey Lushnikov
parent
a02347e3ef
commit
6a8865cd85
@@ -30,8 +30,11 @@ class Keyboard {
|
||||
* @param {string} key
|
||||
* @param {{text: string}=} options
|
||||
*/
|
||||
async down(key, options = {text: ''}) {
|
||||
const {text} = options;
|
||||
async down(key, options = {text: undefined}) {
|
||||
let { text } = options;
|
||||
// If the key is a single character, and no modifiers are pressed except shift, a keypress should be generated by default.
|
||||
if (text === undefined)
|
||||
text = (key.length === 1 && !(this._modifiers & ~8)) ? key : '';
|
||||
const autoRepeat = this._pressedKeys.has(key);
|
||||
this._pressedKeys.add(key);
|
||||
this._modifiers |= this._modifierBit(key);
|
||||
|
||||
Reference in New Issue
Block a user