function keydown (event) {
    switch (event.keyCode) {
      case $mdConstant.KEY_CODE.DOWN_ARROW:
        if (ctrl.loading) return;
        event.stopPropagation();
        event.preventDefault();
        ctrl.index   = Math.min(ctrl.index + 1, ctrl.matches.length - 1);
        updateScroll();
        reportMessages(false, ReportType.Selected);
        break;
      case $mdConstant.KEY_CODE.UP_ARROW:
        if (ctrl.loading) return;
        event.stopPropagation();
        event.preventDefault();
        ctrl.index   = ctrl.index < 0 ? ctrl.matches.length - 1 : Math.max(0, ctrl.index - 1);
        updateScroll();
        reportMessages(false, ReportType.Selected);
        break;
      case $mdConstant.KEY_CODE.TAB:
        // If we hit tab, assume that we've left the list so it will close
        onListLeave();

        if (ctrl.hidden || ctrl.loading || ctrl.index < 0 || ctrl.matches.length < 1) return;
        select(ctrl.index);
        break;
      case $mdConstant.KEY_CODE.ENTER:
        if (ctrl.hidden || ctrl.loading || ctrl.index < 0 || ctrl.matches.length < 1) return;
        if (hasSelection()) return;
        event.stopPropagation();
        event.preventDefault();
        select(ctrl.index);
        break;
      case $mdConstant.KEY_CODE.ESCAPE:
        event.preventDefault(); // Prevent browser from always clearing input
        if (!shouldProcessEscape()) return;
        event.stopPropagation();

        clearSelectedItem();
        if ($scope.searchText && hasEscapeOption('clear')) {
          clearSearchText();
        }

        // Manually hide (needed for mdNotFound support)
        ctrl.hidden = true;

        if (hasEscapeOption('blur')) {
          // Force the component to blur if they hit escape
          doBlur(true);
        }

        break;
      default:
    }
  }
function keydown (event) {
    switch (event.keyCode) {
      case $mdConstant.KEY_CODE.DOWN_ARROW:
        if (ctrl.loading) return;
        event.stopPropagation();
        event.preventDefault();
        ctrl.index   = Math.min(ctrl.index + 1, ctrl.matches.length - 1);
        updateScroll();
        reportMessages(false, ReportType.Selected);
        break;
      case $mdConstant.KEY_CODE.UP_ARROW:
        if (ctrl.loading) return;
        event.stopPropagation();
        event.preventDefault();
        ctrl.index   = ctrl.index < 0 ? ctrl.matches.length - 1 : Math.max(0, ctrl.index - 1);
        updateScroll();
        reportMessages(false, ReportType.Selected);
        break;
      case $mdConstant.KEY_CODE.TAB:
        
        onListLeave();

        if (ctrl.hidden || ctrl.loading || ctrl.index < 0 || ctrl.matches.length < 1) return;
        select(ctrl.index);
        break;
      case $mdConstant.KEY_CODE.ENTER:
        if (ctrl.hidden || ctrl.loading || ctrl.index < 0 || ctrl.matches.length < 1) return;
        if (hasSelection()) return;
        event.stopPropagation();
        event.preventDefault();
        select(ctrl.index);
        break;
      case $mdConstant.KEY_CODE.ESCAPE:
        event.preventDefault(); 
        if (!shouldProcessEscape()) return;
        event.stopPropagation();

        clearSelectedItem();
        if ($scope.searchText && hasEscapeOption('clear')) {
          clearSearchText();
        }

        
        ctrl.hidden = true;

        if (hasEscapeOption('blur')) {
          
          doBlur(true);
        }

        break;
      default:
    }
  }
function keydown ( event ) { switch ( event . keyCode ) { case $mdConstant . KEY_CODE . DOWN_ARROW : if ( ctrl . loading ) return ; event . stopPropagation ( ) ; event . preventDefault ( ) ; ctrl . index = Math . min ( ctrl . index + 1 , ctrl . matches . length - 1 ) ; updateScroll ( ) ; reportMessages ( false , ReportType . Selected ) ; break ; case $mdConstant . KEY_CODE . UP_ARROW : if ( ctrl . loading ) return ; event . stopPropagation ( ) ; event . preventDefault ( ) ; ctrl . index = ctrl . index < 0 ? ctrl . matches . length - 1 : Math . max ( 0 , ctrl . index - 1 ) ; updateScroll ( ) ; reportMessages ( false , ReportType . Selected ) ; break ; case $mdConstant . KEY_CODE . TAB : // If we hit tab, assume that we've left the list so it will close onListLeave ( ) ; if ( ctrl . hidden || ctrl . loading || ctrl . index < 0 || ctrl . matches . length < 1 ) return ; select ( ctrl . index ) ; break ; case $mdConstant . KEY_CODE . ENTER : if ( ctrl . hidden || ctrl . loading || ctrl . index < 0 || ctrl . matches . length < 1 ) return ; if ( hasSelection ( ) ) return ; event . stopPropagation ( ) ; event . preventDefault ( ) ; select ( ctrl . index ) ; break ; case $mdConstant . KEY_CODE . ESCAPE : event . preventDefault ( ) ; // Prevent browser from always clearing input if ( ! shouldProcessEscape ( ) ) return ; event . stopPropagation ( ) ; clearSelectedItem ( ) ; if ( $scope . searchText && hasEscapeOption ( 'clear' ) ) { clearSearchText ( ) ; } // Manually hide (needed for mdNotFound support) ctrl . hidden = true ; if ( hasEscapeOption ( 'blur' ) ) { // Force the component to blur if they hit escape doBlur ( true ) ; } break ; default : } }
Handles keyboard input.
@param event
Handles keyboard input .