ForumsProgramming ForumKeycode problem in AS3

4 3821
Recklusfire1
offline
Recklusfire1
20 posts
Nomad

I'm curious to know why Flash considers non-special keys, such as A and P, to be undefined while special keys, such as Space and Right, to be defined.

This doesn't work...

if (keyboardEvent.keyCode==Keyboard.P) {


...but this does:
if (keyboardEvent.keyCode==Keyboard.SPACE) {


Note: I did import flash.ui.Keyboard.

Thanks for any help.
  • 4 Replies
kevinseven11
offline
kevinseven11
36 posts
Nomad

Is that the exact code that your showing us, becauase maybe somethin else is causin it.

waynaul
offline
waynaul
73 posts
Nomad

The non-special keys are only available in the Adobe Integrated Runtime. I agree that it is puzzling why these constants are not available outside of Adobe AIR.

-Waynaul

clipmaster3
offline
clipmaster3
104 posts
Nomad

I think it has do with flash not letting you reference Keyboard.P when you're not using AIR, so it might work if you plug in the direct value of P rather than a reference to it... P : uint = 80 ... so try 80 instead of Keyboard.P and see if it works

Recklusfire1
offline
Recklusfire1
20 posts
Nomad

I tried using 80 before, but it did not work. Recently, I tried that again. I used some trace functions to detect whether or not the event was being registered.

The outcome was that only the release event was being detected. Yet, the simply fix was disabling the keyboard shortcuts.

But, yes. Using the keycode numbers worked.

Thanks.

Showing 1-4 of 4