在键盘事件中获取鼠标位置 [英] Getting mouse position in keyboard event

查看:173
本文介绍了在键盘事件中获取鼠标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户按住Shift键时,我试图让选择轮出现.

I'm trying to have a selection wheel appear when the user holds down the Shift key.

滚轮应居中于鼠标的位置.

The wheel should be centred on the mouse's position.

但是,当我对此进行测试时,事件对象上的pageXclientX都未定义.

However when I test this, pageX and clientX are both undefined on the event object.

是否可以在键盘事件中获取鼠标坐标?

Is it possible to get the mouse coordinates on a keyboard event?

推荐答案

不,只需跟踪mousemove事件并连续保存当前位置,以防遇到键盘事件.

No, simply track mousemove events and continuously save the current position in case you get a keyboard event.

这篇关于在键盘事件中获取鼠标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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