[Javascript] Cursor location in a text box

Andrew Dunn andrew at d2k.com.au
Wed Oct 2 02:25:04 CDT 2002


I got some further information on this problem, I have got the following
info from a web site, it says there is a layerX, layerY etc properties which
represent the cursor location when a keydown even occurs (which is what I
want). What this doesn't tell me is what object these properties belong to,
does anyone know? I've tried document and the textbox that is getting the
keydown but they both return undefined, (I'm using IE 5, it doesn't need to
support anything else as it is an intranet app) 

KeyDown
Occurs when the user depresses a key. 

Syntax
onKeyDown="handlerText"
Parameters
handlerText is JavaScript code or a call to a JavaScript function. 

Event of
document, Image, Link, and Textarea objects 

Event properties used
type indicates a KeyDown event. 
target indicates the object to which the event was originally sent. 

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor
location at the time the KeyDown event occurred. 

which represents the ASCII value of the key pressed. To get the actual
letter, number, or symbol of the pressed key, use the fromCharCode method.
To set this property when the ASCII value is unknown, use the charCodeAt
method. 

modifiers contains the list of modifier keys held down when the KeyDown
event occurred. 



-----Original Message-----
From: Andrew Dunn [mailto:andrew at d2k.com.au] 
Sent: Wednesday, 2 October 2002 5:03 PM
To: 'javascript at LaTech.edu'
Subject: [Javascript] Cursor location in a text box


Hi,

I want to retreive the cursor location in a text box, I have looked at the
createRange object but it doesn't seem to do what I want as it only gets the
text that is selected.

Is there a way?
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list