# Trigger button state via keyboard press

**URL:** https://forum.kirupa.com/t/trigger-button-state-via-keyboard-press/281230
**Category:** flash
**Created:** [February 6, 2009, 10:32am UTC](https://forum.kirupa.com/t/trigger-button-state-via-keyboard-press/281230 "2009-02-06T10:32:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![koen\_vb](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@koen\_vb](https://forum.kirupa.com/u/koen_vb)
#### Post date: [February 6, 2009, 10:32am UTC](https://forum.kirupa.com/t/trigger-button-state-via-keyboard-press/281230/1 "2009-02-06T10:32:59Z")

</div>

Hi all,

Is there a way to trigger a buttonState for example the upState via actionscript?

I tried this but it seems not to work?

```auto

			
                        two_btn.addEventListener(MouseEvent.MOUSE_OVER,testEvent);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, testkeys);
			
                        private function testkeys(event:Event):void {
				
     			two_btn.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OVER));
     			
				trace("keypress received");

			}
			
			private function testEvent(event:Event):void {
				
				trace("button two clicked");
			}
			

```

I tried to dispatch a mouse event on the button but it seems to be it does not  
work very well…

What I would like to have is something like:

two.btn.setState( “upstate”) on a keyboard press?

Is this possible with the simpleButton Class?

Thx
