Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move mouse pointer in JavaScript

Tags:

javascript

Is it possible to move the mouse so that it is positioned inside a text input using JavaScript?

like image 786
Brian Avatar asked Feb 23 '10 23:02

Brian


People also ask

Can you move cursor in Javascript?

You cannot move the actual mouse pointer in Javascript. You can, however move a pointer shaped image and pretend that you can. :-) Better yet, you can move a cat image around, following the mouse cursor, and try to use it to chase the cursor into the position you want.

How do I move my mouse in node JS?

To move the mouse on windows, you'd need to call the SetCursorPos function from the user32. dll like this: var ffi = require("ffi"); var user32 = ffi.

How do I find my mouse pointer coordinates?

The clientX property returns the horizontal coordinate (according to the client area) of the mouse pointer when a mouse event was triggered. The client area is the current window. Tip: To get the vertical coordinate (according to the client area) of the mouse pointer, use the clientY property.


Video Answer


2 Answers

I don't know about moving the actual rendered mouse pointer, but could you just set the focus on the element?

document.getElementById('the_text_input_id').focus() 
like image 106
jasonbar Avatar answered Sep 19 '22 22:09

jasonbar


Please see this question:

Mouse move on element

Besides that, I think you are committing major design mistake by taking control of any of the users input in any way (maybe besides setting the focus of a form element)

like image 36
JP Silvashy Avatar answered Sep 21 '22 22:09

JP Silvashy