you have to use a key listener -- although I'm not sure how efficient it'll be to do this because ultimately you can only say as many things as there are keys on the keyboard
but it would be something like this:
keylistener = new Object();
keylistener.onKeyUp = function() {
if (Key.getCode() == Key.SHIFT) {
trace("you just pressed the SHIFT key!");
}
};
Key.addListener(keylistener);
and so if you wanted to code a specific sound to play you would have to create a sound object first like:
sound = new Sound();
keylistener = new Object();
keylistener.onKeyUp = function() {
if (Key.getCode() == Key.SHIFT) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushTheShiftKey.mp3", true);
}else if(Key.getCode() == Key.SPACE){
sound.loadSound("theSoundYouWantToPlayWhenYouPushTheSPACEKey.mp3", true);
}
};
Key.addListener(keylistener);
and there's a list of all the various key codes for the keys:
http://people.uncw.edu/tompkinsj/112/flashactionscript/keycodes.htmso you could go:
sound = new Sound();
keylistener = new Object();
keylistener.onKeyUp = function() {
if (Key.getCode() == 48) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushThe0Key.mp3", true);
} else if (Key.getCode() == 49) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushThe1Key.mp3", true);
} else if (Key.getCode() == 50) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushThe2Key.mp3", true);
}//et cetera...
};
Key.addListener(keylistener);
and in order for the sound object you created to play you have to make sure the mp3s are in the same folder as the SWF file
otherwise you have to specify the location with like:
sound.loadSound("someFolder/theNameOfTheMP3.mp3", true);