Adobe AIR 1.5 OS X shift-space bug workaround

Air Love Shift Space

Savvas Malamas just retweeted Mike Chambers's tweet on how the Adobe AIR 1.5 shift-space bug is apparently fixed in an internal build. In doing so, he reminded me to release my own workaround for it so you don't have to wait for the official release to patch your AIR apps. (This is especially true for those Twitter clients out there!)

So, here goes, until the official fix is in, you can use this workaround that extends the TextArea component to re-enable shift-spaces:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:TextArea xmlns:mx="" addedToStage="init(event)">
          // This fixes the shift-space bug in Adobe AIR 1.5
          // Released under the open source MIT License.
          // Copyright (c) 2009 Aral Balkan.


          private function init(event)

          private function keyDownListener(e:KeyboardEvent):void
            // If shift and space are being held down together...
            if (e.keyCode == 32 && e.shiftKey)
              // ... add the space at the current location.
              var caretIndex:int = textField.caretIndex;
              var firstPart:String = textField.text.substr(0, caretIndex);
              var secondPart:String = textField.text.substr(caretIndex, textField.length);
              var newString = firstPart + ' ' + secondPart;
              textField.text = newString;

              var newCaretIndex = caretIndex + 1;

              textField.setSelection(newCaretIndex, newCaretIndex);



(So Twhirl, get to it and implement this already!) :)