@@ -277,16 +277,13 @@ export class StagehandAgentHandler {
277
277
case "keypress" : {
278
278
const { keys } = action ;
279
279
if ( Array . isArray ( keys ) ) {
280
- console . log ( "[Keypress] Received keys:" , keys ) ;
281
-
282
280
// Check if CTRL or CMD is present in the keys
283
281
const hasModifier = keys . some (
284
282
( key ) =>
285
283
key . includes ( "CTRL" ) ||
286
284
key . includes ( "CMD" ) ||
287
285
key . includes ( "COMMAND" ) ,
288
286
) ;
289
- console . log ( "[Keypress] Has modifier keys:" , hasModifier ) ;
290
287
291
288
if ( hasModifier ) {
292
289
// Handle key combination - press all keys simultaneously
@@ -298,87 +295,52 @@ export class StagehandAgentHandler {
298
295
return "Meta" ;
299
296
return this . convertKeyName ( key ) ;
300
297
} ) ;
301
- console . log (
302
- "[Keypress] Converted to Playwright keys:" ,
303
- playwrightKeys ,
304
- ) ;
305
298
306
299
// Press all keys down in sequence
307
- console . log ( "[Keypress] Pressing keys down in sequence..." ) ;
308
300
for ( const key of playwrightKeys ) {
309
- console . log ( "[Keypress] Pressing down:" , key ) ;
310
301
await this . stagehandPage . page . keyboard . down ( key ) ;
311
302
}
312
303
313
304
// Small delay to ensure the combination is registered
314
- console . log (
315
- "[Keypress] Waiting for combination to register..." ,
316
- ) ;
317
305
await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
318
306
319
307
// Release all keys in reverse order
320
- console . log ( "[Keypress] Releasing keys in reverse order..." ) ;
321
308
for ( const key of playwrightKeys . reverse ( ) ) {
322
- console . log ( "[Keypress] Releasing:" , key ) ;
323
309
await this . stagehandPage . page . keyboard . up ( key ) ;
324
310
}
325
- console . log (
326
- "[Keypress] Key combination completed successfully" ,
327
- ) ;
328
311
} catch ( error ) {
329
- console . error (
330
- "[Keypress] Error executing key combination:" ,
331
- error ,
332
- ) ;
333
312
throw error ;
334
313
}
335
314
} else {
336
315
// Handle individual keys as before
337
- console . log ( "[Keypress] Processing individual keys..." ) ;
338
316
for ( const key of keys ) {
339
- console . log ( "[Keypress] Processing key:" , key ) ;
340
317
// Handle special keys
341
318
if ( key . includes ( "ENTER" ) ) {
342
- console . log ( "[Keypress] Pressing special key: Enter" ) ;
343
319
await this . stagehandPage . page . keyboard . press ( "Enter" ) ;
344
320
} else if ( key . includes ( "SPACE" ) ) {
345
- console . log ( "[Keypress] Pressing special key: Space" ) ;
346
321
await this . stagehandPage . page . keyboard . press ( " " ) ;
347
322
} else if ( key . includes ( "TAB" ) ) {
348
- console . log ( "[Keypress] Pressing special key: Tab" ) ;
349
323
await this . stagehandPage . page . keyboard . press ( "Tab" ) ;
350
324
} else if ( key . includes ( "ESCAPE" ) || key . includes ( "ESC" ) ) {
351
- console . log ( "[Keypress] Pressing special key: Escape" ) ;
352
325
await this . stagehandPage . page . keyboard . press ( "Escape" ) ;
353
326
} else if ( key . includes ( "BACKSPACE" ) ) {
354
- console . log ( "[Keypress] Pressing special key: Backspace" ) ;
355
327
await this . stagehandPage . page . keyboard . press ( "Backspace" ) ;
356
328
} else if ( key . includes ( "DELETE" ) ) {
357
- console . log ( "[Keypress] Pressing special key: Delete" ) ;
358
329
await this . stagehandPage . page . keyboard . press ( "Delete" ) ;
359
330
} else if ( key . includes ( "ARROW_UP" ) ) {
360
- console . log ( "[Keypress] Pressing special key: ArrowUp" ) ;
361
331
await this . stagehandPage . page . keyboard . press ( "ArrowUp" ) ;
362
332
} else if ( key . includes ( "ARROW_DOWN" ) ) {
363
- console . log ( "[Keypress] Pressing special key: ArrowDown" ) ;
364
333
await this . stagehandPage . page . keyboard . press ( "ArrowDown" ) ;
365
334
} else if ( key . includes ( "ARROW_LEFT" ) ) {
366
- console . log ( "[Keypress] Pressing special key: ArrowLeft" ) ;
367
335
await this . stagehandPage . page . keyboard . press ( "ArrowLeft" ) ;
368
336
} else if ( key . includes ( "ARROW_RIGHT" ) ) {
369
- console . log ( "[Keypress] Pressing special key: ArrowRight" ) ;
370
337
await this . stagehandPage . page . keyboard . press ( "ArrowRight" ) ;
371
338
} else {
372
339
// For other keys, use the existing conversion
373
340
const playwrightKey = this . convertKeyName ( key ) ;
374
- console . log (
375
- "[Keypress] Pressing converted key:" ,
376
- playwrightKey ,
377
- ) ;
378
341
await this . stagehandPage . page . keyboard . press ( playwrightKey ) ;
379
342
}
380
343
}
381
- console . log ( "[Keypress] Finished processing all individual keys" ) ;
382
344
}
383
345
}
384
346
return { success : true } ;
0 commit comments