Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

list of keyCodes?

New Here ,
Mar 12, 2008 Mar 12, 2008
Hello. I'm new to AS3, so go easy on me. =-)

I have code that enables some very basic manipulation of some test movie clips; rotating, scaling, etc. based on keyboard inputs.

However, these keyboard events are limited to the F keys, Enter, Delete, NumPad, i.e. the standard set of non-alphanumeric keys.

How do I get the movies to respond to the user pressing 'q', for example, or 't', or really any other 'mainstream' keyboard buttons? Is there a list of keyCodes out there that can help me, or am I thinking this through at the wrong angle? Thanks for any help. =-)

-dE
TOPICS
ActionScript
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 12, 2008
Deggz,

> Is there a list of keyCodes out there that can help me, or am I
> thinking this through at the wrong angle? Thanks for any help. =-)

Nah, your angle is fine ... for some reason, I always find the list of
key codes hard to locate, too. Use the Help panel to search the phrase
"Keyboard Keys and Key Code Values," and that'll bring it up. It's listed
in the "Learning ActionScript 2.0" book of the Help docs, but the codes are
the same for AS3.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2008 Mar 12, 2008
Thanks, Dave. I found it. I should mention I've enjoyed your webiste and gleaned from it mroe than a few solutions.

A follow-up question:

Now that I have the key Code values, how would I get the code to recognize the input? Here is what I have so far:

If I wanted to change the F4 key to say, A (keyCode 65), what is the syntax for managing that process?

Thanks again!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 12, 2008 Mar 12, 2008
In your case statements, use the value for the key code, ie,
case 65: // means F4 was pushed
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2008 Mar 12, 2008
Many, many thanks! Worked like a charm. This AS3.0 syntax is taking me a little while to ramp up on.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 12, 2008
Deggz,

>>> Thanks, Dave. I found it. I should mention I've enjoyed
>>> your webiste and gleaned from it mroe than a few solutions

That's nice to hear; thanks!

> Many, many thanks [to dzedward]! Worked like a charm. This
> AS3.0 syntax is taking me a little while to ramp up on.

It all comes with time and practice. :)

Note that the constants of the Keyboard class (Keyboard.F1, Keyboard.F2,
etc.) are really just stand-ins for numbers. Like dz said, you're just
putting numbers into your switch() statements ... it's just that some number
stand-alone, while others -- typically, commonly used keys -- have constants
that keep you from having to remember their numbers.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2008 Oct 13, 2008
Can you write that code out? I don't understand. I you saying these two lines are the same...

case Keyboard.F4:

case 65
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 11, 2009 Feb 11, 2009
LATEST
AS3 monkey, he wrote that code 2 years ago. It's a little late to respond
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2008 Mar 12, 2008
Hiya,

Since you're talking about keycodes...is Flash limited to two maximum at once or something?

If I press Up Arrow + Left Arrow and then try to fire (spacebar) it won't fire. It seems that it only accepts two keys at a time.

Anyone know?

[EDIT]Actually, it only snags one at a time. I'm assuming I'll need to do the inspecting on my own for the other keys since this is event driven.[/EDIT]


(p.s. thanks for the keyboard codes and great blog, David!)

-K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 12, 2008
Krylar,

> Since you're talking about keycodes...is Flash limited to two
> maximum at once or something?

No, but it's a bit tougher to detect multiple keys in AS3.

> If I press Up Arrow + Left Arrow and then try to fire (spacebar) it won't
> fire. It seems that it only accepts two keys at a time.
>
> Anyone know?

See if this helps ... it's a good article.

http://www.kirupa.com/forum/showpost.php?p=2098269&postcount=319

> (p.s. thanks for the keyboard codes and great blog, David!)

Thanks!


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2008 Mar 12, 2008
David,

Thanks for the link. Look like I'm on the right track as I've just coded up something very similar to what's in that article.

Thanks again.

-K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 13, 2008 Mar 13, 2008
yay, I always lose the keyCode values myself!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 21, 2008 Aug 21, 2008
hi all i'm kinda stuck.. any help you can offer would help..
i've located the key code / ascii code

i'm working on a video player and i'm trying to add key code..
i can get every key but the a-z keys to work with a case / switch

i've tried every combo of keyCode and Assci but none seem to work
what am i doing wrong?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines