setPosition not working inside listener

tellKeyListener = new Object();
tellKeyListener.onKeyUp = function () {
    if (Key.getAscii() == ord('t') && inputMsg.htmlText == "t") {
  inputMsg.htmlText = "/tell ";
  inputMsg.setSelection(6,6);
 } 
}
Key.addListener(tellKeyListener);

I have this listener added to the chat room here on this site, and everything works except the setting of the cursor to the end of the "/tell ". It currently puts it between the “/” and the “t” (where the regular ‘t’ would go). I tried breaking it out of the if statement, but it still did not move the cursor.

How can I place the cursor at the end of the text string "/tell "?