Skip to content

Commit bc810c7

Browse files
authored
Merge pull request #336 from Frnk1996/patch-2
Add withKeyDown documentation
2 parents 1490fc6 + ff06b03 commit bc810c7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

browser-testing.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ $page = visit('/')
281281
[text](#text)
282282
[attribute](#attribute)
283283
[keys](#keys)
284+
[withKeyDown](#withKeyDown)
284285
[type](#type)
285286
[typeSlowly](#type-slowly)
286287
[select](#select)
@@ -921,6 +922,20 @@ $page->keys('input[name=password]', 'secret');
921922
$page->keys('input[name=password]', ['{Control}', 'a']); // Keyboard shortcuts
922923
```
923924

925+
<a name="withKeyDown"></a>
926+
### withKeyDown
927+
928+
The `withKeyDown` method executes the given callback while a key is held down:
929+
930+
```php
931+
$page->withKeyDown('Shift', function () use ($page): void {
932+
$page->keys('#input', ['KeyA', 'KeyB', 'KeyC']);
933+
}); // writes "ABC"
934+
```
935+
936+
> Note: To respect held keys like Shift, use key codes such as KeyA, KeyB, KeyC.
937+
> 'a' always types a lowercase “a” and 'A' always types an uppercase “A”, regardless of modifiers.
938+
924939
<a name="type"></a>
925940
### type
926941

0 commit comments

Comments
 (0)