Perhaps caret () is what you are looking for (pageX and pageY will not work for a div); The following link may help:
jQuery: get cursor position of text in input without browser code?
if you want to use the coordinates of the document, you can use the following, but it will respond to keystrokes anywhere on the page, and not just in the text box (if you use a div instead, e.pageX will be undefined)
$(document).keypress(function(e) { var code = (e.keyCode ? e.keyCode : e.which); if (e.ctrlKey && code == 32) { alert(e.pageX);
user2377420
source share