开发者

How to detect mouse acceleration in javascript?

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

I'd like to detect the mous开发者_如何学编程e 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.

Cheers


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);

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜