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

Method pressKey

lib/helper/Playwright.js:2227–2251  ·  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

2225 * {{> pressKeyWithKeyNormalization }}
2226 */
2227 async pressKey(key) {
2228 await checkFocusBeforePressKey(this, key)
2229 const modifiers = []
2230 if (Array.isArray(key)) {
2231 for (let k of key) {
2232 k = getNormalizedKey.call(this, k)
2233 if (isModifierKey(k)) {
2234 modifiers.push(k)
2235 } else {
2236 key = k
2237 break
2238 }
2239 }
2240 } else {
2241 key = getNormalizedKey.call(this, key)
2242 }
2243 for (const modifier of modifiers) {
2244 await this.page.keyboard.down(modifier)
2245 }
2246 await this.page.keyboard.press(key)
2247 for (const modifier of modifiers) {
2248 await this.page.keyboard.up(modifier)
2249 }
2250 return this._waitForAction()
2251 }
2252
2253 /**
2254 * {{> type }}

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected