I am writing an HTML5 game, and I want users to be able to control their character’s direction by moving the mouse left/right.
I can get mouse movement with onmousemove and pageX and pageY, but once the mouse hits the edge of the screen… too bad for you.
Is there any cross-browser way around this (perhaps getting actual mouse movement instead of cursor position)?
If not, can I set the mouse cursor to be in the middle of an element if it reaches the edge, and just allow them to move their mouse out of the element vertically?
This is not possible unless you contain the page within a native app for your target platform(s) or you request the page fullscreen for the game, which modern browsers support.
https://developer.mozilla.org/en/DOM/Using_full-screen_mode
http://hacks.mozilla.org/2012/01/using-the-fullscreen-api-in-web-browsers/
Here’s things to keep in mind:
*This may be possible with flash though, not sure.