How to show mouse cursor in browser while typing?
On Mac OS/X in both Firefox and Chrome, the mouse cursor disappears when I type. Is there anyway in javascript to prevent this behavior or to force the cursor to become visible again?
I'm using jquery for the keyboard开发者_如何学Python handling:
// keyboard handlers
$(document).keydown(this.keydown);
$(document).keyup(this.keyup);
...
keydown: function(evt) {
var app = PGE_LIB.game();
switch(evt.which) {
case 'G'.charCodeAt(0):
app.activateGrabTool();
break;
case 'S'.charCodeAt(0):
$('#toolbar img').removeClass('activeTool');
$('#scaleTool').addClass('activeTool');
break;
case app.ESC_KEY:
app.deactivateTool();
break;
case app.SHIFT_KEY:
app._shiftKeyDown = true; break;
default:
break;
}
},
This is expected behaviour in those browsers. Behaviour the users expect. There is, thankfully, no way to disable this.
Personally, I find many of the UI decision on OS X to be infuriating, but since it is standard behaviour in OS X, altering this would certainly go contrary to the user's expectations.
EDIT
I don't have a mac available to me at the moment, so I can:t test this, but see http://api.jquery.com/event.preventDefault/
you can use event.preventDefault()
to alter default behaviour of some elements. It doesn't always work, and afaik the disappearing mouse cursor issue is an OS-wide behaviour, not browser specific.
If you're using custom cursors, when your key event fires, you can detect the cursor position and display an image in its place until the next mousemove
. In this case, you should also hide the image for un-handled key events. And if you're not using custom cursors, be aware that you will probably be presenting some users with a different version of the standard cursor than their OS or browser or user-installed cursor set displays.
Sorry, but you can't disable this built-in operating system feature through the browser.
精彩评论