* _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([puppeteer/puppeteer#1313](https://github.com/puppeteer/puppeteer/issues/1313)). * * {{> pressKeyWithKeyNormalization }}
(key)
| 1539 | * {{> pressKeyWithKeyNormalization }} |
| 1540 | */ |
| 1541 | async pressKey(key) { |
| 1542 | await checkFocusBeforePressKey(this, key) |
| 1543 | const modifiers = [] |
| 1544 | if (Array.isArray(key)) { |
| 1545 | for (let k of key) { |
| 1546 | k = getNormalizedKey.call(this, k) |
| 1547 | if (isModifierKey(k)) { |
| 1548 | modifiers.push(k) |
| 1549 | } else { |
| 1550 | key = k |
| 1551 | break |
| 1552 | } |
| 1553 | } |
| 1554 | } else { |
| 1555 | key = getNormalizedKey.call(this, key) |
| 1556 | } |
| 1557 | for (const modifier of modifiers) { |
| 1558 | await this.page.keyboard.down(modifier) |
| 1559 | } |
| 1560 | await this.page.keyboard.press(key) |
| 1561 | for (const modifier of modifiers) { |
| 1562 | await this.page.keyboard.up(modifier) |
| 1563 | } |
| 1564 | return this._waitForAction() |
| 1565 | } |
| 1566 | |
| 1567 | /** |
| 1568 | * {{> type }} |
no test coverage detected