为什么在Mac浏览器中按下metaKey时,Javascript为什么会丢弃keyUp事件? [英] Why does Javascript drop keyUp events when the metaKey is pressed on Mac browsers?

查看:202
本文介绍了为什么在Mac浏览器中按下metaKey时,Javascript为什么会丢弃keyUp事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac浏览器上,当metakey按下时,javascript不会收到大多数键的keyup事件(其他修饰符似乎是一个例外).使用此jsfiddle进行演示(将结果放在焦点上并尝试使用cmd + x之类的方法,x将不会收到keyup事件): http://jsfiddle.net/mUEaV/

On Mac browsers, javascript does not receive keyup events for most keys (other modifier keys seem to be an exception) when the metakey is down. Use this jsfiddle to demonstrate (focus the result area and try something like cmd + x, the x will not receive a keyup event): http://jsfiddle.net/mUEaV/

我已经在Chrome,FF,Safari和Opera的稳定版本中重现了这一点. Windows 7中的控制键似乎没有发生相同的事情.

I've reproduced this in stable releases for Chrome, FF, Safari and Opera. The same thing does not seem to happen with the control key in Windows 7.

操作系统劫持了keyup事件吗?这似乎特别奇怪,因为使用metakey的命令(例如save,find,cut,cut,copy等)全部在keydown而不是keyup上激活,并且可以被javascript劫持.

Is the OS hijacking the keyup event? This seems especially strange since commands that use the metakey such as save, find, cut, copy, etcetera all activate on keydown not on keyup, and can be hijacked by the javascript just fine.

推荐答案

当我使用meta时,根本不可能获得onKeyUp事件.非常不幸,很难解决.您必须以其他方式模拟它们.

It's simply not possible to get the onKeyUp events when meta is used, I learned today. Very unfortunate and difficult to work around. You'll have to emulate them some other way.

编辑:为澄清起见,这仅在Mac上发生,并且是由于对该事件的操作系统级别处理而发生的. 它不能被覆盖.很抱歉成为坏消息的承担者.

To clarify, this is only on Mac and occurs due to OS level handling of the event. It cannot be overridden. Sorry to be the bearer of bad news.

这篇关于为什么在Mac浏览器中按下metaKey时,Javascript为什么会丢弃keyUp事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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