473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Assigning specific key presses

I have this bit of code that at the moment moves the flash to the specific scene and frame at the press of any key on the keyboard.
However, I want to modify this so that it works with specific a specific key, such as when I press A as opposed to any key.

I've played around with it a bit and I've searched the forums but couldn't find anything that worked. Any suggestions?

var keyListener:Object = new Object();
keyListener.onKeyUp = function() {
// trace("UP -> Code: "+Key.getCode()+"\tASCII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii()));
gotoAndPlay("Scene 1", 29);
};
Key.addListener(keyListener);
Aug 29 '07 #1
2 2219
I'm a douche, that code is pretty much it. It even has a note on how to tell me how to input specific keys. *headdesk.*

Well, for those with similiar problems, this is the code I ended up using:

keylistener = new Object();
keylistener.onKeyDown = function() {
if (Key.getAscii() == 97)
gotoAndPlay("Hmph", 1);
};
Key.addListener(keylistener);

(Responds to lowercase a only, uppercase is ASCII 65)
Aug 31 '07 #2
Two things
1. to make script that will react to anky key pressed you simply
onClipEvent(keyDown){
2.to make it a specific key do this
onClipEvent(enterFrame){
if(Key.isDown("Key.A")){
///put your reaction here
Jan 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Sandman | last post by:
I have a script that generates a hierarchical menu, but I am having problems assigning styles to each manu items different possible states. The possible states a menu item can be in is (and all of...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
5
by: Phil Latio | last post by:
I have 2 virtually identical tables and wish to move data between them. Basically one table is called "live_table" and the other is named "suspended_table" and the only difference is that the...
3
by: Zen Clark | last post by:
I am new to this group, and to this language... So, hello. I was wondering for a project idea on how to get a program to register and respond to key presses on a console (Or really anything...
3
by: David Lozzi | last post by:
Howdy, I'm using asp.net 2.0 and am trying to get one text box on the page, after the user presses enter, to "click" a specific button. I copied the javascript I used for a .net 1.1 web app I...
2
by: petedawn | last post by:
guys, i want to capture all the function key presses from F1 to F12. now i want that when the user presses F1 from within the browser i should display a alert window saying that they have...
17
by: Cliff | last post by:
Hi, I'm in the process of porting some code from a 3rd party and have hit a problem with the following: typedef struct { unsigned char Red; unsigned char Green; unsigned char Blue;...
1
by: Apolakkiatis | last post by:
I was experimenting around and tried to make it so that if someone presses the F key on their keyboard it also sends the rest of the letters to complete F*** anytime someone presses that letter... I...
2
by: mygirl22 | last post by:
Hi, I used this code to created 2 combo boxes General and Specific...and Only show Specific (Combo B) when Combo A is chosen..... What i need now is to know how to assign specific values to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.