可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I am amazed that this bug has been sitting there for ages. There seems to be a workaround using generic events. Here's a demo: http://jsbin.com/awenaq/3
回答2:
It looks like it's been a bit since you asked this so you may have already found the answer to your question. In case you haven't though, there is a bug in Webkit as was pointed out in this SO question that causes the keyCode to always be 0. Apparently there's not much you can do until they fix it. Sadly it doesn't look like anyone is really working on it though. It's not the answer you want to hear, but it's really the only answer anyone can give you for this right now.
回答3:
I have faced same issue with Android devices like, Sony Xperia and HTC Devices. So i found alternate solution: please refer to my answer for this question KeyCode Returns 0 Always
回答4:
It is not a bug... this feature is being weeded out, deprecated, forbidden, whateva' the name will be tomorrow... You cannot rely on this feature to work for long. ...and is a wide open security risk... find another way to do what you are trying to do. Consult the MOZILLA specs and you will see the BIG BAD RED BANNER which warns to avoid this like the plague. They will not fix it, by returning 0 they effectively stop the bleeding without changing the code except in one place where it always zaps the keyCode to 0.
回答5:
If you have jQuery:
$.Event(event, { keyCode: 13 });
This is the intended use.
Source.