Event.keycode在mozilla中不起作用 [英] Event.keycode is not working in mozilla

查看:89
本文介绍了Event.keycode在mozilla中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





event.keycode在Mozilla .pl z中不起作用,有没有解决方案可以解决这个问题。

i尝试了谷歌的其他选项。

就像我在下面使用这个但仍然无法工作

Hi,

event.keycode is not working in Mozilla .pl z, is there any solutions to fix this issue.
i tried with other option from Google.
like i used this below but still not working

(event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);





我试过的:





What I have tried:

i tried with other option from Google.
like i used this below but still not working
 <pre>(event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);

推荐答案

参见KeyboardEvent.keyCode - Web API | MDN [ ^ ]:

See KeyboardEvent.keyCode - Web APIs | MDN[^]:
Quote:

如果可能,你应该避免使用它;它已经被弃用了一段时间。相反,你应该使用KeyboardEvent.code,如果它已经实现。不幸的是,有些浏览器仍然没有它,因此您必须小心确保使用所有目标浏览器都支持的浏览器。谷歌浏览器和Safari已经实现了KeyboardEvent.keyIdentifier,它是在规范草案中定义的,但不是最终规范。

You should avoid using this if possible; it's been deprecated for some time. Instead, you should use KeyboardEvent.code, if it's implemented. Unfortunately, some browsers still don't have it, so you'll have to be careful to make sure you use one which is supported on all target browsers. Google Chrome and Safari have implemented KeyboardEvent.keyIdentifier, which was defined in a draft specification but not the final spec.



另请参阅链接上的示例代码,该代码检查是否有可用性。各种活动成员。我不知道为什么不首先检查推荐的 KeyboardEvent.code - Web API | MDN [ ^ ]属性应该适用于最近的Mozilla浏览器。



但请注意,返回值因属性本身(使用代码属性)(使用过的浏览器)而异和操作系统。你必须处理所有这些情况。因此,最好的解决方案是避免使用密钥代码。


See also the example code at the link which checks for the availability of the various event members. I don't know why that is not checking first for the recommended KeyboardEvent.code - Web APIs | MDN[^] property which should work with recent Mozilla browsers.

But note that returned values differ for the property itself (with the code property), the used browser, and the operating system. You would have to handle all these cases. So the best solution would be to avoid using key codes at all.


这篇关于Event.keycode在mozilla中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆