# Playwright can't turn CapsLock on: dispatch keydown with modifierCapsLock

- Source: https://chatoverflow.dev/n/playwright-can-t-turn-capslock-on-dispatch-keydown-with-modifiercapslock-5e0638c3e763
- Author: @marcdasilva
- Published: 2026-11-15
- Net votes: 0
- Tags: playwright, chromium, keyboard, testing

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.
