ASCII value from a key stroke

keycode ASCII display in a dynamic text box

Page 1 of 1

2 Replies - 15634 Views - Last Post: 19 September 2006 - 12:27 PM

#1 Maxx   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 16-September 06

ASCII value from a key stroke

Post icon  Posted 19 September 2006 - 08:00 AM

Don't mean to double post but didn't want it hidden in my other post.
I can not get a ASCII value from a key stroke display in a text box. Any idea's? Let me know if this works for you. -Thanks

Here is the Code:

 tence:String = new String();
var keyListener:Object = new Object();
keyListener.onkeydown = function() {
myText.text += String.fromCharCode(Key.getAscii());
trace("\tThe Key code is: "+Key.getCode());
trace("\tThe ASCII value is: "+Key.getAscii());

if ((Key.getCode()) == (13)) {
myPlay.play();
}
};
Key.addListener(keyListener);




Is This A Good Question/Topic? 0
  • +

Replies To: ASCII value from a key stroke

#2 Maxx   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 16-September 06

Re: ASCII value from a key stroke

Posted 19 September 2006 - 08:46 AM

Okay I've gotten it to show in the text box but how do you display the keystroke/Askii/Keycode in a format like this????:

Example:
The Key code is: 65
The ASCII value is: 97
The key pressed is: A



 var keyListener:Object = new Object();
keyListener.onkeydown = function() {
	myText.text += Key.getAscii();
	trace("\tThe Key code is: "+Key.getCode());
	trace("\tThe ASCII value is: "+Key.getAscii());
	if ((Key.getCode()) == (13)) {
		myPlay.play();
	}
};
Key.addListener(keyListener);


This post has been edited by Maxx: 19 September 2006 - 08:47 AM

Was This Post Helpful? 0
  • +
  • -

#3 Maxx   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 16-September 06

Re: ASCII value from a key stroke

Post icon  Posted 19 September 2006 - 12:27 PM

Thanks Sandro,

Sometimes I miss the little thing(well most the time)
I forgot the "+newline"


So here is the code that works:
I also included an X/Y mouse poit finder:

 var sentence:String = new String();
var keyListener:Object = new Object();
keyListener.onkeydown = function() {
	myText.text="Ascii#"+Key.getAscii()+newline;
	myText.text+="keycode#"+Key.getCode();
	
	if ((Key.getCode()) == (13)) {
		myPlay.play();
	}
};
Key.addListener(keyListener);



Mouse listener:
 watchMouse = new Object();
watchMouse.onmousemove = function() {
		displayMouse_txt.text="Table X position is "+_xmouse+newline;
		displayMouse_txt.text+="Table Y position is "+_ymouse;
		
};
Mouse.addListener(watchMouse);







Thank you Sandro for your help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1