PDA

View Full Version : Keylistener not working for Home key



thegrrraue
April 19th, 2008, 10:16 PM
So I've got this code running:

var keyListener_obj:Object = new Object();
keyListener_obj.onKeyDown = function() {
if (Key.isDown(Key.HOME)) {
gotoAndStop(1);
}
};
Key.addListener(keyListener_obj);

And it doesn't work. I've tried adding a trace on it, and it appears that flash isn't even seeing that the home key is being pressed. The code works fine if I make the key one of the arrow keys.

I also tried putting the number for Home (36) instead of the word home (so it looks like this (Key.36) ) but it still doesn't work. Does anyone know why?


EDIT: So it appears that it DOES work, but only if the focus is on one of the input text boxes...

glosrfc
April 19th, 2008, 11:08 PM
Works fine:

var keyListener_obj:Object = new Object();
keyListener_obj.onKeyDown = function() {
if (Key.isDown(Key.HOME)) {
trace("home key");
}
};
Key.addListener(keyListener_obj);

I'm not sure why an input box would affect it.