MCPcopy
hub / github.com/microsoft/vscode / sendKeybinding

Method sendKeybinding

test/automation/src/playwrightDriver.ts:537–565  ·  view source on GitHub ↗
(keybinding: string, accept?: () => Promise<void> | void)

Source from the content-addressed store, hash-verified

535 }
536
537 async sendKeybinding(keybinding: string, accept?: () => Promise<void> | void) {
538 const chords = keybinding.split(' ');
539 for (let i = 0; i < chords.length; i++) {
540 const chord = chords[i];
541 if (i > 0) {
542 await this.wait(100);
543 }
544
545 if (keybinding.startsWith('Alt') || keybinding.startsWith('Control') || keybinding.startsWith('Backspace')) {
546 await this.page.keyboard.press(keybinding);
547 return;
548 }
549
550 const keys = chord.split('+');
551 const keysDown: string[] = [];
552 for (let i = 0; i < keys.length; i++) {
553 if (keys[i] in PlaywrightDriver.vscodeToPlaywrightKey) {
554 keys[i] = PlaywrightDriver.vscodeToPlaywrightKey[keys[i]];
555 }
556 await this.page.keyboard.down(keys[i]);
557 keysDown.push(keys[i]);
558 }
559 while (keysDown.length > 0) {
560 await this.page.keyboard.up(keysDown.pop()!);
561 }
562 }
563
564 await accept?.();
565 }
566
567 async click(selector: string, xoffset?: number | undefined, yoffset?: number | undefined) {
568 const { x, y } = await this.getElementXY(selector, xoffset, yoffset);

Callers 1

dispatchKeybindingMethod · 0.80

Calls 8

waitMethod · 0.95
startsWithMethod · 0.80
downMethod · 0.80
upMethod · 0.80
splitMethod · 0.65
pushMethod · 0.65
acceptFunction · 0.50
popMethod · 0.45

Tested by

no test coverage detected