B2G/gecko/browser/devtools/webconsole/webconsole.js
/**
   * The inputNode "keypress" event handler.
   *
   * @param nsIDOMEvent aEvent
   */
The inputNode "keypress" event handler.
The inputNode " keypress " event handler .
function JSTF_keyPress(aEvent)
  {
    if (aEvent.ctrlKey) {
      switch (aEvent.charCode) {
        case 97:
          this.inputNode.setSelectionRange(0, 0);
          aEvent.preventDefault();
          break;
        case 101:
          this.inputNode.setSelectionRange(this.inputNode.value.length,
                                           this.inputNode.value.length);
          aEvent.preventDefault();
          break;
        default:
          break;
      }
      return;
    }
    else if (aEvent.shiftKey &&
        aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_RETURN) {
      return;
    }
    let inputUpdated = false;
    switch(aEvent.keyCode) {
      case Ci.nsIDOMKeyEvent.DOM_VK_ESCAPE:
        if (this.autocompletePopup.isOpen) {
          this.clearCompletion();
          aEvent.preventDefault();
        }
        break;
      case Ci.nsIDOMKeyEvent.DOM_VK_RETURN:
        if (this.autocompletePopup.isOpen && this.autocompletePopup.selectedIndex > -1) {
          this.acceptProposedCompletion();
        }
        else {
          this.execute();
        }
        aEvent.preventDefault();
        break;
      case Ci.nsIDOMKeyEvent.DOM_VK_UP:
        if (this.autocompletePopup.isOpen) {
          inputUpdated = this.complete(this.COMPLETE_BACKWARD);
        }
        else if (this.canCaretGoPrevious()) {
          inputUpdated = this.historyPeruse(HISTORY_BACK);
        }
        if (inputUpdated) {
          aEvent.preventDefault();
        }
        break;
      case Ci.nsIDOMKeyEvent.DOM_VK_DOWN:
        if (this.autocompletePopup.isOpen) {
          inputUpdated = this.complete(this.COMPLETE_FORWARD);
        }
        else if (this.canCaretGoNext()) {
          inputUpdated = this.historyPeruse(HISTORY_FORWARD);
        }
        if (inputUpdated) {
          aEvent.preventDefault();
        }
        break;
      case Ci.nsIDOMKeyEvent.DOM_VK_TAB:
        if (this.complete(this.COMPLETE_HINT_ONLY) &&
            this.lastCompletion &&
            this.acceptProposedCompletion()) {
          aEvent.preventDefault();
        }
        else {
          this.updateCompleteNode(l10n.getStr("Autocomplete.blank"));
          aEvent.preventDefault();
        }
        break;
      default:
        break;
    }
  }
function JSTF_keyPress ( aEvent ) { if ( aEvent . ctrlKey ) { switch ( aEvent . charCode ) { case 97 : this . inputNode . setSelectionRange ( 0 , 0 ) ; aEvent . preventDefault ( ) ; break ; case 101 : this . inputNode . setSelectionRange ( this . inputNode . value . length , this . inputNode . value . length ) ; aEvent . preventDefault ( ) ; break ; default : break ; } return ; } else if ( aEvent . shiftKey && aEvent . keyCode == Ci . nsIDOMKeyEvent . DOM_VK_RETURN ) { return ; } let inputUpdated = false ; switch ( aEvent . keyCode ) { case Ci . nsIDOMKeyEvent . DOM_VK_ESCAPE : if ( this . autocompletePopup . isOpen ) { this . clearCompletion ( ) ; aEvent . preventDefault ( ) ; } break ; case Ci . nsIDOMKeyEvent . DOM_VK_RETURN : if ( this . autocompletePopup . isOpen && this . autocompletePopup . selectedIndex > - 1 ) { this . acceptProposedCompletion ( ) ; } else { this . execute ( ) ; } aEvent . preventDefault ( ) ; break ; case Ci . nsIDOMKeyEvent . DOM_VK_UP : if ( this . autocompletePopup . isOpen ) { inputUpdated = this . complete ( this . COMPLETE_BACKWARD ) ; } else if ( this . canCaretGoPrevious ( ) ) { inputUpdated = this . historyPeruse ( HISTORY_BACK ) ; } if ( inputUpdated ) { aEvent . preventDefault ( ) ; } break ; case Ci . nsIDOMKeyEvent . DOM_VK_DOWN : if ( this . autocompletePopup . isOpen ) { inputUpdated = this . complete ( this . COMPLETE_FORWARD ) ; } else if ( this . canCaretGoNext ( ) ) { inputUpdated = this . historyPeruse ( HISTORY_FORWARD ) ; } if ( inputUpdated ) { aEvent . preventDefault ( ) ; } break ; case Ci . nsIDOMKeyEvent . DOM_VK_TAB : if ( this . complete ( this . COMPLETE_HINT_ONLY ) && this . lastCompletion && this . acceptProposedCompletion ( ) ) { aEvent . preventDefault ( ) ; } else { this . updateCompleteNode ( l10n . getStr ( "Autocomplete.blank" ) ) ; aEvent . preventDefault ( ) ; } break ; default : break ; } }
The inputNode "keypress" event handler.
The inputNode " keypress " event handler .
// control-a // control-e // shift return // TODO: expand the inputNode height by one line // Generate a completion and accept the first proposed value.