ChromeDevTools / devtools-protocol

Chrome DevTools Protocol
https://chromedevtools.github.io/devtools-protocol/
BSD 3-Clause "New" or "Revised" License
1.15k stars 226 forks source link

Input.dispatchKeyEvent cannot send hyphen #248

Closed danny519 closed 3 years ago

danny519 commented 3 years ago

Whatever I try, I just can't get Input.dispatchKeyEvent to type a hyphen in my chrome extension. I have tried using type: "char" with the text: "-" but nothing happens, I also tried using keyDown with nativeVirtualKeyCode(189), code and key.

chrome.debugger.sendCommand(target, 'Input.dispatchKeyEvent', {
    type: 'keyDown',
    code: 'Minus',
    nativeVirtualKeyCode: 189,
    unmodifiedText: '-'
});
chrome.debugger.sendCommand(target, 'Input.dispatchKeyEvent', {
    type: 'keyUp',
    code: 'Minus',
    nativeVirtualKeyCode: 189,
    unmodifiedText: '-'
});

this is my latest attempt to get it to work. I am new to chrome devtools protocol so sorry if this is a rookie question, I just could not find anything about it when I googled it.

pbi-qfs commented 3 years ago

I had no problems sending the hyphen to a text edit on a website using these params of Input.dispatchKeyEvent:

{"type":"rawKeyDown","modifiers":0,"code":"Minus","key":"Minus","windowsVirtualKeyCode":189}
{"type":"char","modifiers":0,"text":"-","unmodifiedText":"-","code":"Minus","key":"Minus","windowsVirtualKeyCode":189}
{"type":"keyUp","modifiers":0,"text":"","unmodifiedText":"","code":"Minus","key":"Minus","windowsVirtualKeyCode":189}
danny519 commented 3 years ago

thanks, that worked for me, not sure what part of that fixed it.

danny519 commented 3 years ago

it also works with double colons too.