For flash people this is probably easy, but it gave me a slight headache: I want to catch a couple of keys in a TextField and do things; but since the key has also been catched by the control, a black square appears (in my case) which I’d rather not have. Since the KEY_DOWN event is not cancellable and I couldn’t find a solution with the propagation phase / priority, I did end up cancelling TEXT_INPUT itself:
addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
addEventListener(TextEvent.TEXT_INPUT, cancelKey);
private function onKeyDown(event:KeyboardEvent):void
{
cancelChar = false;
if ((event.ctrlKey) && (event.charCode == "b".charCodeAt(0))) {
cancelChar = true;
}
}
private function cancelKey(event:TextEvent):void
{
if (cancelChar) {
event.preventDefault();
cancelChar = false;
}
}