# Wat is the action script for keyboard input?

**URL:** <https://forum.kirupa.com/t/wat-is-the-action-script-for-keyboard-input/101964>\
**Category:** Uncategorized\
**Created:** [February 18, 2004, 11:38am UTC](https://forum.kirupa.com/t/wat-is-the-action-script-for-keyboard-input/101964 "2004-02-18T11:38:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![whitetulips](https://avatars.discourse-cdn.com/v4/letter/w/ba9def/32.png) [@whitetulips](https://forum.kirupa.com/u/whitetulips)\
**Post date:** [February 18, 2004, 11:38am UTC](https://forum.kirupa.com/t/wat-is-the-action-script-for-keyboard-input/101964/1 "2004-02-18T11:38:44Z")

</div>

i have created 12 piano keyboard keys on my screen… i want my users to have keyboard input using the computer keyboard  
eg: the letter ‘a’ for the piano key “a”

when the user press “a” on the computer keyboard, the sound of that key should also apprear…  
wats the action script?  
pls help…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 12:19pm UTC](https://forum.kirupa.com/t/wat-is-the-action-script-for-keyboard-input/101964/2 "2004-02-18T12:19:50Z")

</div>

[AS]  
onClipEvent (enterFrame) {  
if (Key.isDown(Key.getCode() == 65)) { // not sure if it should be = or == here… swich if it doesn’t work  
trace(“A is down”);  
} else if (Key.isDown(Key.getCode() == 66)) {  
trace(“B is down”);  
}  
}  
[/AS]

here’s some links.

this one describes the keyCode() function, with which you will check which key is pressed.  
[http://livedocs.macromedia.com/flash/mx2004/main/12\_as269.htm#wp236226](http://livedocs.macromedia.com/flash/mx2004/main/12_as269.htm#wp236226)

this one displays a list of every key, A-Z and 0-9  
[http://livedocs.macromedia.com/flash/mx2004/main/appx\_c\_2.htm](http://livedocs.macromedia.com/flash/mx2004/main/appx_c_2.htm)

then just use the blue arrowkeyss at the top of the page to check other keyCodes.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 2:36pm UTC](https://forum.kirupa.com/t/wat-is-the-action-script-for-keyboard-input/101964/3 "2004-02-18T14:36:57Z")

</div>

On the timeline:

```auto

listen = new Object();
listen.onKeyDown = function(){
if(Key.isDown(65)){
//play sound a
}
}
Key.addListener(listen);

```

The page Kalliban provided is pretty useful:  
[http://livedocs.macromedia.com/flash/mx2004/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash\_MX\_2004\_Documentation&file=appx\_c\_2.htm](http://livedocs.macromedia.com/flash/mx2004/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004_Documentation&file=appx_c_2.htm)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 6:40pm UTC](https://forum.kirupa.com/t/wat-is-the-action-script-for-keyboard-input/101964/4 "2004-02-18T18:40:43Z")

</div>

thanks… i’ll try it n c whether it works…
