Chrome Devtools“ Issystemkey”调试器属性

发布于 2025-02-13 08:18:20 字数 1128 浏览 0 评论 0原文

查看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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文