# Working with input ## Fill out the form, enter text ```js await page.fill('#name', 'Peter'); ``` This is the easiest way to fill out the form fields. It focuses the element and triggers an `input` event with the entered text. It works for ``, ` await page.type('#area', 'Hello World!'); ``` Sometimes it is important to type into the focused field character by character, as if it was the user with the real keyboard. This method will emit all the necessary keyboard events, with all the `keydown`, `keyup`, `keypress` events in place. You can even specify the optional `delay` between the key presses to simulate real user behavior. #### API reference - [`page.type(selector, text[, options])`](./api.md#pagetypeselector-text-options) — on the main frame - [`frame.type(selector, text[, options])`](./api.md#frametypeselector-text-options) — on a specific frame - [`elementHandle.type(text[, options])`](./api.md#elementhandletypetext-options) — on a particular element - [`keyboard.type(text[, options])`](./api.md#keyboardtypetext-options) — wherever the current focus is
## Press a key, enter keyboard shortcut ```js // await page.press('#submit', 'Enter'); // await page.press('#name', 'Control+ArrowRight'); // await page.press('#value', '$'); ``` This method focuses the selected element and produces a single keystroke. It accepts the logical key names that are emitted in the [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) property of the keyboard events: ``` Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, ArrowDown, End, Enter, Home, Insert, PageDown, PageUp, ArrayRight, ArrowUp, F1 - F12, Digit0 - Digit9, KeyA - KeyZ, etc. ``` - You can alternatively specify a single character you'd like to produce such as `"a"` or `"#"`. - Following modification shortcuts are also suported: `Shift, Control, Alt, Meta`. #### Variations ```js // await page.press('#name', '$'); ``` Simple version produces a single character. This character is case-sensitive, so `"a"` and `"A"` will produce different results. ```js // await page.press('#name', 'Shift+A'); // await page.press('#name', 'Shift+ArrowLeft'); ``` Shortcuts such as `"Control+o"` or `"Control+Shift+T"` are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed. Note that you still need to specify the capital `A` in `Shift-A` to produce the capital character. `Shift-a` produces a lower-case one as if you had the `CapsLock` toggled. #### API reference - [`page.press(selector, key[, options])`](./api.md#pagepressselector-key-options) — on the main frame - [`frame.press(selector, key[, options])`](./api.md#framepressselector-key-options) — on a specific frame - [`elementHandle.press(key[, options])`](./api.md#elementhandlepresskey-options) — on a particular element - [`keyboard.press(key[, options])`](./api.md#keyboardpresskey-options) — wherever the current focus is