如何在JavaScript中检测鼠标加速? [英] How to detect mouse acceleration in javascript?

查看:88
本文介绍了如何在JavaScript中检测鼠标加速?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在记录Web应用程序中的鼠标移动.

I'm logging the mouse movements in a web app.

我想检测平台(例如Windows)上的鼠标加速.是否有可能通过javascript做到这一点,甚至只是以一种近似的方式?我可以要求用户使用调查表检查其设置,但是自动检测它会更好.

I'd like to detect the mouse acceleration on a platform (e.g. Windows). Is it possible to do it from javascript, even just in an approximated way? I could ask the user to check their settings with a questionnaire, but it would be much better to detect it automatically.

欢呼

推荐答案

检查鼠标在设定的时间间隔内移动的距离:

Check distance the mouse has moved over a set interval of time:

var mX:Number = _xmouse;
var mY:Number = _ymouse;

function checkDistance()
{
    clear();
    //trace('new distance: ' + Math.sqrt(Math.pow((mY - _ymouse), 2) + Math.pow((mX - _xmouse), 2)));
    lineStyle(1, 0x000000);
    moveTo(mX, mY);
    lineTo(_xmouse, _ymouse);
    mX = _xmouse;
    mY = _ymouse;
}

setInterval(checkDistance, 1000);

来自 http://www.kirupa.com/forum/showthread. php?t = 332961

这篇关于如何在JavaScript中检测鼠标加速?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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