Chrome Devtools“ Issystemkey”调试器属性
查看chrome.debugger.sendcommand
文档时,我遇到了一个属性, issystemkey 。我想知道是否可以使用它来验证键是由人类还是程序键入(类似于iStrusted
事件属性),但是在其上似乎没有任何文档,链接的URL或其他地方。据我所知,没有提及它的用法。
那么这个布尔属性做什么?
一些示例代码要说明,给定一个字符c
,一个选项卡ID tab_id
以及当前附加到同一选项卡的调试器:
let options = {
'key': c,
'type': 'keyDown',
'nativeVirtualKeyCode': c.charCodeAt(),
'windowsVirtualKeyCode': c.charCodeAt(),
'macVirtualKeyCode': c.charCodeAt(),
'isSystemKey': true // What does this change, compared to its falsy default?
}
// Pressing key
chrome.debugger.sendCommand({tabId: tab_id}, "Input.dispatchKeyEvent", options, () => {
// Releasing key
options.type = 'keyUp';
chrome.debugger.sendCommand({tabId: tab_id}, "Input.dispatchKeyEvent", options, () => {
// Detaching debugger
chrome.debugger.detach({tabId: tab_id});
});
});
While looking into chrome.debugger.sendCommand
documentation, I came across an attribute, isSystemKey. I wonder whether this could be used to verify whether a key is typed by a human or program (similar to the isTrusted
event attribute), but there doesn't appear to be any documentation on it, in the linked URL or elsewhere. Not a mention of its usage, as far as I can see.
So what does this boolean attribute do?
Some example code to illustrate, given a character c
, a tab id tab_id
and the debugger currently attached to that same tab:
let options = {
'key': c,
'type': 'keyDown',
'nativeVirtualKeyCode': c.charCodeAt(),
'windowsVirtualKeyCode': c.charCodeAt(),
'macVirtualKeyCode': c.charCodeAt(),
'isSystemKey': true // What does this change, compared to its falsy default?
}
// Pressing key
chrome.debugger.sendCommand({tabId: tab_id}, "Input.dispatchKeyEvent", options, () => {
// Releasing key
options.type = 'keyUp';
chrome.debugger.sendCommand({tabId: tab_id}, "Input.dispatchKeyEvent", options, () => {
// Detaching debugger
chrome.debugger.detach({tabId: tab_id});
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论