MCPcopy
hub / github.com/codeceptjs/CodeceptJS / pressKey

Method pressKey

lib/helper/Puppeteer.js:1541–1565  ·  view source on GitHub ↗

* _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([puppeteer/puppeteer#1313](https://github.com/puppeteer/puppeteer/issues/1313)). * * {{> pressKeyWithKeyNormalization }}

(key)

Source from the content-addressed store, hash-verified

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 }}

Callers 11

Playwright_test.jsFile · 0.45
WebDriver_test.jsFile · 0.45
Puppeteer_test.jsFile · 0.45
testsFunction · 0.45
within_test.jsFile · 0.45
coverage_test.jsFile · 0.45
github_test.jsFile · 0.45

Calls 4

_waitForActionMethod · 0.95
checkFocusBeforePressKeyFunction · 0.90
isModifierKeyFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected