import { toPage } from '../../../utils' ; import { Frame , Page } from 'playwright' ; export interface KeyboardPressOptions { type { number } memberof delay : number ; } export type KeyboardKey = '.' | ' ' | '-' | '[' | ']' | '{' | '}' | '*' | '+' | '=' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'A' | 'Add' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'b' | 'B' | 'Backquote' | 'Backslash' | 'Backspace' | 'c' | 'C' | 'd' | 'D' | 'Delete' | 'Digit0' | 'Digit1' | 'Digit2' | 'Digit3' | 'Digit4' | 'Digit5' | 'Digit6' | 'Digit7' | 'Digit8' | 'Digit9' | 'Divide' | 'e' | 'E' | 'Enter' | 'Equal' | 'Escape' | 'f' | 'F' | 'F1' | 'F10' | 'F11' | 'F12' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'g' | 'G' | 'h' | 'H' | 'Home' | 'i' | 'I' | 'Insert' | 'j' | 'J' | 'k' | 'K' | 'KeyA' | 'KeyB' | 'KeyC' | 'KeyD' | 'KeyE' | 'KeyF' | 'KeyG' | 'KeyH' | 'KeyI' | 'KeyJ' | 'KeyK' | 'KeyL' | 'KeyM' | 'KeyN' | 'KeyO' | 'KeyP' | 'KeyQ' | 'KeyR' | 'KeyS' | 'KeyT' | 'KeyU' | 'KeyV' | 'KeyW' | 'KeyX' | 'KeyY' | 'KeyZ' | 'l' | 'L' | 'm' | 'M' | 'Minus' | 'Multiply' | 'n' | 'N' | 'o' | 'O' | 'p' | 'P' | 'PageDown' | 'PageUp' | 'q' | 'Q' | 'r' | 'R' | 's' | 'S' | 'Subtract' | 't' | 'T' | 'Tab' | 'u' | 'U' | 'v' | 'V' | 'w' | 'W' | 'x' | 'X' | 'y' | 'Y' | 'z' | 'Z' ; export const defaultKeyboardPressOptions = { delay : 50 , } ; export async function pressKey ( key , page , options ) { if ( ! page ) { throw new Error ( `Cannot press key '${ key }' because no browser has been launched` ) ; } await toPage ( page ) . keyboard . press ( key , options ) ; }