I created a KeyPressForwarder
that "forwards" the key press as a click:
package com.sophware.backend
{
import flash.events.IEventDispatcher;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
public class KeyPressForwarder
{
public function dispatchAsClickEvent(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.ENTER)
{
var dispatcher:IEventDispatcher = evt.target as IEventDispatcher;
dispatcher.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
}
}
}
And then setup a binding:
<mx:Button
id="Name"
keyUp="_keyPressForwarder.dispatchAsClickEvent(event)"
click="addOrModifyEntry(event)"
/>
You could eliminate the class and just use the function as the concept is generic. Just make sure you have a click
handler to handle the forwarded event.