function keyDownListener(e:KeyboardEvent):void
{
trace(e.keyCode)
if(e.keyCode == LEFT)
{
keyPressedLeft = true;
}
if(e.keyCode == UP)
{
keyPressedUp = true;
}
if(e.keyCode == RIGHT)
{
keyPressedRight = true;
}
if(e.keyCode == DOWN)
{
keyPressedDown = true;
}
if(e.keyCode == W)
{
keyPressedW = true;
}
if(e.keyCode == A)
{
keyPressedA = true;
}
if(e.keyCode == S)
{
keyPressedS = true;
}
if(e.keyCode == D)
{
keyPressedD = true;
}
if(e.keyCode == RETURN)
{
keyPressedReturn = true;
}
}
Keyboard events not getting all keys AS3
Page 1 of 17 Replies - 1669 Views - Last Post: 21 June 2012 - 05:32 AM
#1
Keyboard events not getting all keys AS3
Posted 07 June 2012 - 10:44 AM
So I have a problem, approximately half the keys on my keyboard are not traced, including the A, S and Return keys required by the game I am writing, here is the keyDownListener function, I am almost certain the actual code is correct, but am hoping someone can enlighten me on an error or of a problem with flash that causes this
Replies To: Keyboard events not getting all keys AS3
#2
Re: Keyboard events not getting all keys AS3
Posted 07 June 2012 - 10:51 AM
What are the values of LEFT,W etc?
Have you tried using if(e.KeyCode == Keyboard.LEFT)
Have you tried using if(e.KeyCode == Keyboard.LEFT)
#3
Re: Keyboard events not getting all keys AS3
Posted 07 June 2012 - 11:13 AM
space is one of the keys that works which is why return is missing and space has been replaced, Return was 32. the constants represent the keys value according to flash.
var keyPressedLeft:Boolean; var keyPressedUp:Boolean; var keyPressedRight:Boolean; var keyPressedDown:Boolean; var keyPressedW:Boolean; var keyPressedA:Boolean; var keyPressedS:Boolean; var keyPressedD:Boolean; var keyPressedSpace:Boolean; const LEFT = 37; const UP = 38; const RIGHT = 39; const DOWN = 40; const W = 87; const A = 65; const S = 83; const D = 68; const SPACE = 32;
#4
Re: Keyboard events not getting all keys AS3
Posted 07 June 2012 - 11:16 AM
When you press a key and trace the e.keyCode(), what values are you getting?
For example when you hit the left arrow, what keycode is displayed?
For example when you hit the left arrow, what keycode is displayed?
#5
Re: Keyboard events not getting all keys AS3
Posted 07 June 2012 - 11:22 AM
Apologies, Return Key was 13 Not 32
All the correct keycodes are displaying however, not all the keys are being tracked, for example, i require W,A,S,D, Return, Up Left Down and Right, all but A and S are got by flash when traced, on further analysis, i discovered that approx half of the keys are not got when i do:
Here is where my problem lies
87
85
68
71
88
in fact when traced, only these 5 keys appear in console after pressing all the alphabet only
All the correct keycodes are displaying however, not all the keys are being tracked, for example, i require W,A,S,D, Return, Up Left Down and Right, all but A and S are got by flash when traced, on further analysis, i discovered that approx half of the keys are not got when i do:
trace(e.keyCode)
Here is where my problem lies
87
85
68
71
88
in fact when traced, only these 5 keys appear in console after pressing all the alphabet only
#6
Re: Keyboard events not getting all keys AS3
Posted 07 June 2012 - 11:24 AM
Hang on so you mean the keyCode is not what you think it should be or the trace is not even being executed?
You don't have a strange international keyboard do you?
You don't have a strange international keyboard do you?
#7
Re: Keyboard events not getting all keys AS3
Posted 07 June 2012 - 11:28 AM
Normal Dell qwerty Keyboard, the problem is the keys are not being picked up by flash at all, with trace(e.keyCode) all key presses should be output to console, so why am a missing most of the alphabet? sorry, im new if you couldnt tell
but no matter what, tracing that should output all keypresses
#8
Re: Keyboard events not getting all keys AS3
Posted 21 June 2012 - 05:32 AM
This works fine for me:s which keys are missing?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|