# Navigation with keyboard

**URL:** <https://forum.kirupa.com/t/navigation-with-keyboard/306508>\
**Category:** flash\
**Created:** [March 16, 2010, 8:20pm UTC](https://forum.kirupa.com/t/navigation-with-keyboard/306508 "2010-03-16T20:20:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hausnfranz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hausnfranz/32/2427_2.png) [@Hausnfranz](https://forum.kirupa.com/u/Hausnfranz)\
**Post date:** [March 16, 2010, 8:20pm UTC](https://forum.kirupa.com/t/navigation-with-keyboard/306508/1 "2010-03-16T20:20:40Z")

</div>

I am trying to set up some code that lets a user navigate (highlight and then select) a set of buttons using the keyboard.

I am getting this error : Line 40, 1136: Incorrect number of arguments. Expected 1.

I just want the function **highlightButton();** to be called whenever a key is pressed. The function finds out which button is targeted via an array.

I must not understand events in as3 yet because I always get errors when I try to called functions by just putting it in there.

```auto

stop();

import flash.display.*;
import flash.events.TimerEvent;
import flash.utils.Timer;

var highlightedButton=0;

var holdButtons:Array = new Array();

holdButtons[0]="btn1";
holdButtons[1]="btn2";
holdButtons[2]="btn3";
holdButtons[3]="btn4";
holdButtons[4]="btn5";

function highlightButton(event:Event) {
    //button mc go to highlight state
    holdButtons[highlightedButton].gotoAndStop("highlight");
    trace("BUTTON :" + highlightedButton);
}

stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);

function KeyPressed(evt:KeyboardEvent):void {
    switch (evt.keyCode) {
        case Keyboard.UP :
            trace("up");
            --highlightedButton;
            highlightButton();
            break;
        case Keyboard.DOWN :
            trace("down");
            ++highlightedButton;
            highlightButton();
            break;
            /**
        case Keyboard.LEFT :
            trace("left");
            break;
        case Keyboard.RIGHT :
            trace("right");
            break;
            **/
    }
}

```
