I'm working for a foundation that raises awareness for accessibility in the internet. For a presentation, we want to offer a small workshop that simulates different disabilities/impairments to people. This is done via a website created especially for this presentation.
One of the demonstrated impairments is having a tremor, which means experiencing shaky, difficult-to-control hand movements. With this impairment, it's very difficult to move the mouse cursor exactly and to press the mouse button while the mouse is over a link. Both some old people and people with disease, e.g. Parkinson's, can suffer from tremor.
Now I'd like to somehow move the mouse cursor in an unpredictable way, so that it's very hard for people to click on a small button. Because JavaScript doesn't allow moving the mouse cursor directly, I'm looking for other ways to achieve this. I came up with the following ideas:
While the first idea would be pretty cool, I couldn't find a tool like this, whether for Mac nor for Windows. And I don't have any skills in programming such a thing myself.
The second idea seems a bit clumsy, but it would achieve the desired effect, I think.
Does anybody have another idea?
I made a quick demo of something that you hopefully should be able to base your code on, using the Pointer Lock API.
I forked this pointer-lock-demo repo and modified it to add a random movement element.
Here is the link to my GitHub page: https://aristocrates.github.io/pointer-lock-demo
And here is the link to my repo: https://github.com/aristocrates/pointer-lock-demo
The javascript code of importance is contained in app.js
, in the canvasLoop(e)
method.
The only thing I changed from the original demo was after the lines
x += movementX * 2;
y += movementY * 2;
I added two lines to represent random movement:
x += Math.floor(Math.random()*3 - 1);
y += Math.floor(Math.random()*3 - 1);
There are still plenty of things you could improve, but hopefully this can help you get started.