# Disabling key presses

**URL:** <https://forum.kirupa.com/t/disabling-key-presses/61063>\
**Category:** Uncategorized\
**Created:** [August 15, 2004, 2:35pm UTC](https://forum.kirupa.com/t/disabling-key-presses/61063 "2004-08-15T14:35:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joecohen](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joecohen](https://forum.kirupa.com/u/joecohen)\
**Post date:** [August 15, 2004, 2:35pm UTC](https://forum.kirupa.com/t/disabling-key-presses/61063/1 "2004-08-15T14:35:40Z")

</div>

I was wondering if anyone can help - I am creating a dancing game:

[http://www.handsomeboymodelingschool.co.uk/games/dancingjoe/](http://www.handsomeboymodelingschool.co.uk/games/dancingjoe/)

I need to disable the keyboard after each key is pressed, so if the user presses the UP key untill the character has finihsed doing the move no other key can be pressed.

is this possible?

---

<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:** [August 15, 2004, 8:54pm UTC](https://forum.kirupa.com/t/disabling-key-presses/61063/2 "2004-08-15T20:54:45Z")

</div>

If you post the code/fla, I can help you out.

---

<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:** [August 15, 2004, 9:36pm UTC](https://forum.kirupa.com/t/disabling-key-presses/61063/3 "2004-08-15T21:36:53Z")

</div>

when the user presses a key, for example: UP, set a variable saying that the guy is dancing, and whenever the user presses any key, it runs a test to see if the guy is dancing, and if he is, then it won’t do anything, if he isn’t, then it’ll make him dance. only once the dancing animation has comleted will the variable be set to equal ‘the guy not dancing’, for example, we might have this:

in the joe movieclip:

```auto
onClipEvent(enterFrame) {
if (Key.isDown(Key.UP)) {
 if(isDancing != true) {
  isDancing = true;
  //code to make joe dance;
 } 
}
if (Key.isDown(Key.DOWN)) {
 if(isDancing != true) {
  isDancing = true;
  //code to make joe dance differently;
 }
}

```

also, at the end of every animation of joe dancing, we must use:

```auto
dancing = false;

```

Hope this helps you :hugegrin:

---

<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:** [August 15, 2004, 11:41pm UTC](https://forum.kirupa.com/t/disabling-key-presses/61063/4 "2004-08-15T23:41:11Z")

</div>

Cyberathlete, I think you made a typo (Then again, it could be my rookie comprehension). At the end of every animation, it should say

```auto
_root.isDancing = false;

```

---

<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:** [August 16, 2004, 12:41am UTC](https://forum.kirupa.com/t/disabling-key-presses/61063/5 "2004-08-16T00:41:45Z")

</div>

if u post the FLA i can help you out.

---

<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:** [August 16, 2004, 9:22am UTC](https://forum.kirupa.com/t/disabling-key-presses/61063/6 "2004-08-16T09:22:43Z")

</div>

this was a great help, exactly what i was after.

cheers 🙂
