@@ -99,6 +99,30 @@ func (k *Keyboard) down(key string) error {
99
99
return nil
100
100
}
101
101
102
+ func (k * Keyboard ) up (key string ) error {
103
+ keyInput := keyboardlayout .KeyInput (key )
104
+ layout := keyboardlayout .GetKeyboardLayout (k .layoutName )
105
+ if _ , ok := layout .ValidKeys [keyInput ]; ! ok {
106
+ return fmt .Errorf ("'%s' is not a valid key for layout '%s'" , key , k .layoutName )
107
+ }
108
+
109
+ keyDef := k .keyDefinitionFromKey (keyInput )
110
+ k .modifiers &= ^ k .modifierBitFromKeyName (keyDef .Key )
111
+ delete (k .pressedKeys , keyDef .KeyCode )
112
+
113
+ action := input .DispatchKeyEvent (input .KeyUp ).
114
+ WithModifiers (input .Modifier (k .modifiers )).
115
+ WithKey (keyDef .Key ).
116
+ WithWindowsVirtualKeyCode (keyDef .KeyCode ).
117
+ WithCode (keyDef .Code ).
118
+ WithLocation (keyDef .Location )
119
+ if err := action .Do (cdp .WithExecutor (k .ctx , k .session )); err != nil {
120
+ return fmt .Errorf ("unable to mouse down: %w" , err )
121
+ }
122
+
123
+ return nil
124
+ }
125
+
102
126
func (k * Keyboard ) insertText (text string ) error {
103
127
action := input .InsertText (text )
104
128
if err := action .Do (cdp .WithExecutor (k .ctx , k .session )); err != nil {
@@ -227,30 +251,6 @@ func (k *Keyboard) typ(text string, opts *KeyboardOptions) error {
227
251
return nil
228
252
}
229
253
230
- func (k * Keyboard ) up (key string ) error {
231
- keyInput := keyboardlayout .KeyInput (key )
232
- layout := keyboardlayout .GetKeyboardLayout (k .layoutName )
233
- if _ , ok := layout .ValidKeys [keyInput ]; ! ok {
234
- return fmt .Errorf ("'%s' is not a valid key for layout '%s'" , key , k .layoutName )
235
- }
236
-
237
- keyDef := k .keyDefinitionFromKey (keyInput )
238
- k .modifiers &= ^ k .modifierBitFromKeyName (keyDef .Key )
239
- delete (k .pressedKeys , keyDef .KeyCode )
240
-
241
- action := input .DispatchKeyEvent (input .KeyUp ).
242
- WithModifiers (input .Modifier (k .modifiers )).
243
- WithKey (keyDef .Key ).
244
- WithWindowsVirtualKeyCode (keyDef .KeyCode ).
245
- WithCode (keyDef .Code ).
246
- WithLocation (keyDef .Location )
247
- if err := action .Do (cdp .WithExecutor (k .ctx , k .session )); err != nil {
248
- return fmt .Errorf ("unable to mouse down: %w" , err )
249
- }
250
-
251
- return nil
252
- }
253
-
254
254
// Down
255
255
func (k * Keyboard ) Down (key string ) {
256
256
rt := k6common .GetRuntime (k .ctx )
0 commit comments