Hi Im trying to determine if an (enter) has occured within an input field. I have a feeling the character I need to test against may be different on a MAC and on a PC. So was hoping to get some feedback as to what results you get on your computer.
on my mac the following example always traces out “RETURN” when I hit return.
To test you will need to add an input textfield to the stage and call it “tf” then place this code on a frame.
tf.addEventListener (KeyboardEvent.KEY_UP,checkKey);
function checkKey (e:KeyboardEvent) {
//
for (var i=0; i<tf.text.length; i++) {
var char = tf.text.charAt(i);
if (char == "\r") {
trace ("RETURN");
}
if(char == "
") {
trace ("NEWLINE");
}
if(char != "
" && char != "\r" ) {
trace (char);
}
}
trace ("-------------------\r");
}
It would be a great help if you could check this out!
CHeers