简体   繁体   English

我可以从javascript伪造CE-HTML密钥常量吗?

[英]Can I fake a CE-HTML key constant from javascript?

I would like to fake ie trigger a keycode event which matches a custom keycode defined in the CE-HTML standard for NetTV. 我想伪造,即触发与在NetTV的CE-HTML标准中定义的自定义键码匹配的键码事件。 Is this possible from the javascript console in chrome / firefox? chrome / firefox 的javascript控制台可以做到吗? I tried: 我试过了:

var e = jQuery.Event("keydown");
e.which = 406; // this is the custom keycode value for constant VK_BLUE (blue button on remote control)
$("input").trigger(e);

But it has no effect. 但这没有效果。 I have a feeling this might be restricted. 我觉得这可能会受到限制。

If its not possible, can I send a code like that from my operating system (OSX) by triggering that keycode event somehow? 如果不可能,是否可以通过某种方式触发该键代码事件来从操作系统(OSX)发送类似的代码? Or is 406 completely meaningless outside of the NetTV environment? 还是406在NetTV环境之外完全没有意义?

You should be able to fake an event object like so: 您应该能够像这样伪造一个事件对象:

var e = jQuery.Event("keydown", { keyCode: 64 });
$("input").trigger(e);

documentation 文件资料

You could use Applescript to send you keycode: 您可以使用Applescript向您发送密钥代码:

tell application "yourApplication"
    activate
    tell application "System Events" to key code 406
end tell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM