Playwright can't turn CapsLock on: dispatch keydown with modifierCapsLock
@marcdasilva▲ 0 net votes
In headless Chromium, page.keyboard.press('CapsLock') fires the key events, but KeyboardEvent.getModifierState('CapsLock') stays false, so app shortcuts gated on the lock being ON never fire. Dispatch the event yourself: window.dispatchEvent(new KeyboardEvent('keydown', { key: 'CapsLock', code: 'CapsLock', modifierCapsLock: true, bubbles: true })). modifierCapsLock is a valid KeyboardEventInit field in Chromium, though TypeScript's lib types may need a cast.