Skip to Content
Pipeline Stages

Key Overlay

Show shortcuts and held modifiers as a keycap on the video.

.keyOverlay() shows key presses from the trace as a keycap at the bottom center of the frame: Ctrl + Z, Esc, Shift + Tab, or Alt + drag for a modifier held over a mouse action.

await Recast
  .from('./traces')
  .parse()
  .cursorOverlay()
  .keyOverlay()
  .render()
  .toFile('demo.mp4')

Presses come from keyboard.press(), keyboard.down() / up(), locator.press(), and a click's modifiers option. Text from fill(), type(), pressSequentially() and keyboard.type() never shows.

What shows

inputs entryShowsDefault
'combos'A key with Ctrl, Alt or Meta, or Shift with a named key: Ctrl + Z, Shift + Tabyes
'special'A named key alone: Esc, Enter, Del, Backspace, arrows, F-keysyes
'mouse-modifiers'A modifier held over a click, drag or wheel turn: Alt + drag, Shift + clickyes
'keys'Any other single key: A, Shift + Ano

Override it for one interaction from the test with withKeyOverlay().

Options

OptionTypeDefaultDescription
inputsKeyOverlayInput[]['combos', 'special', 'mouse-modifiers']Presses that show
labelsRecord<string, string>see belowLabels by Playwright key name, merged over the defaults; also click, drag, wheel
separatorstring' + 'Between keys
minShowMsnumber1200Shortest time a press shows, in output ms; a held key shows until released. The next press replaces it.
position'bottom' | 'top''bottom'; 'top' with burned-in subtitlesEdge of the frame; above a URL bar on the same edge
fontSizenumber32Text size at 1080p, scaled with the output
fontFilestringfontconfig defaultFont file for the text
colorstring'#FFFFFF'Text color
backgroundstring'#1F2328'Keycap color
backgroundOpacitynumber0.85Keycap opacity

Default labels are platform-neutral: Control and ControlOrMeta show as Ctrl, Escape as Esc, Delete as Del, arrows as Up / Down / Left / Right, PageUp / PageDown as PgUp / PgDn, single characters upper-case.

.keyOverlay({
  inputs: ['combos', 'mouse-modifiers'],
  labels: { Control: 'Strg', drag: 'Ziehen' },
})
  • Drawn on the output frame after zoom, like the URL bar. Needs ffmpeg's drawtext; not with direct() yet.
  • Presses inside hidden steps do not show.
  • Burned-in subtitles draw on top of the bottom edge, so with render({ burnSubtitles: true }) the keycap defaults to the top.

On this page