Skip to content

Commit 047997a

Browse files
authored
Add withKeyDown documentation
1 parent 90542f2 commit 047997a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

browser-testing.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ pest()->browser()->timeout(10);
262262
[text](#text)
263263
[attribute](#attribute)
264264
[keys](#keys)
265+
[withKeyDown](#withKeyDown)
265266
[type](#type)
266267
[select](#select)
267268
[append](#append)
@@ -892,6 +893,22 @@ $page->keys('input[name=password]', 'secret');
892893
$page->keys('input[name=password]', ['{Control}', 'a']); // Keyboard shortcuts
893894
```
894895

896+
<a name="withKeyDown"></a>
897+
### withKeyDown
898+
899+
The `withKeyDown` method executes the given callback while a key is held down:
900+
901+
```php
902+
$page->withKeyDown('Shift', function () use ($page): void {
903+
$page->keys('#input', ['KeyA', 'KeyB', 'KeyC']);
904+
}); // writes "ABC"
905+
```
906+
907+
> Note: To respect held keys like Shift, use key codes such as KeyA, KeyB, KeyC.
908+
> 'a' always types a lowercase “a” and 'A' always types an uppercase “A”, regardless of modifiers.
909+
910+
911+
895912
<a name="type"></a>
896913
### type
897914

0 commit comments

Comments
 (0)