Loading web tool...

Back

Get Cursor Position

How to get the position of the cursor.

Close
Rotate layout Save code Display size: 0x0
Copy code
var

cursor

=

{

x

:

0

,

y

:

0

}

;

Note

document

.

addEventListener

(

'mousemove'

,

getCursorPosition

)

;

Note
function

getCursorPosition

(

event

) {


\t

cursor

.

x

=

event

.

pageX

;


\t

cursor

.

y

=

event

.

pageY

;


}

A bare-basic example/template demonstrating how to get the X and Y position of the cursor/mouse relative to the web page.


You can also implement

BT-JS

into your script to more easily access information about the cursor!

Element version: 1.0 (Last updated: January 21, 2024)