nl_tokens: Handles keyboard input .
pl_tokens: 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 ; <mask> $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 : } }