library/src/main/java/com/devbrackets/android/exomedia/ui/widget/VideoControlsLeanback.java
@Override
        public boolean onKey(View view, int keyCode, KeyEvent event) {
            if (event.getAction() != KeyEvent.ACTION_DOWN) {
                return false;
            }

            switch (keyCode) {
                case KeyEvent.KEYCODE_BACK:
                    if (isVisible) {
                        hideDelayed(0);
                        return true;
                    }
                    break;

                case KeyEvent.KEYCODE_DPAD_UP:
                    showTemporary();
                    return true;

                case KeyEvent.KEYCODE_DPAD_DOWN:
                    hideDelayed(0);
                    return true;

                case KeyEvent.KEYCODE_DPAD_LEFT:
                    showTemporary();
                    focusPrevious(currentFocus);
                    return true;

                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    showTemporary();
                    focusNext(currentFocus);
                    return true;

                case KeyEvent.KEYCODE_DPAD_CENTER:
                    showTemporary();
                    currentFocus.callOnClick();
                    return true;

                case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                    onPlayPauseClick();
                    return true;

                case KeyEvent.KEYCODE_MEDIA_PLAY:
                    if (videoView != null && !videoView.isPlaying()) {
                        videoView.start();
                        return true;
                    }
                    break;

                case KeyEvent.KEYCODE_MEDIA_PAUSE:
                    if (videoView != null && videoView.isPlaying()) {
                        videoView.pause();
                        return true;
                    }
                    break;

                case KeyEvent.KEYCODE_MEDIA_NEXT:
                    onNextClick();
                    return true;

                case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                    onPreviousClick();
                    return true;

                case KeyEvent.KEYCODE_MEDIA_REWIND:
                    onRewindClick();
                    return true;

                case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
                    onFastForwardClick();
                    return true;
            }

            return false;
        }
/**
         * NOTE: the view is not always the currently focused view, thus the
         * {@link #currentFocus} variable
         */
the view is not always the currently focused view, thus the
#currentFocus variable
the view is not always the currently focused view thus the #currentFocus variable
@Override
        public boolean onKey(View view, int keyCode, KeyEvent event) {
            if (event.getAction() != KeyEvent.ACTION_DOWN) {
                return false;
            }
            switch (keyCode) {
                case KeyEvent.KEYCODE_BACK:
                    if (isVisible) {
                        hideDelayed(0);
                        return true;
                    }
                    break;
                case KeyEvent.KEYCODE_DPAD_UP:
                    showTemporary();
                    return true;
                case KeyEvent.KEYCODE_DPAD_DOWN:
                    hideDelayed(0);
                    return true;
                case KeyEvent.KEYCODE_DPAD_LEFT:
                    showTemporary();
                    focusPrevious(currentFocus);
                    return true;
                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    showTemporary();
                    focusNext(currentFocus);
                    return true;
                case KeyEvent.KEYCODE_DPAD_CENTER:
                    showTemporary();
                    currentFocus.callOnClick();
                    return true;
                case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                    onPlayPauseClick();
                    return true;
                case KeyEvent.KEYCODE_MEDIA_PLAY:
                    if (videoView != null && !videoView.isPlaying()) {
                        videoView.start();
                        return true;
                    }
                    break;
                case KeyEvent.KEYCODE_MEDIA_PAUSE:
                    if (videoView != null && videoView.isPlaying()) {
                        videoView.pause();
                        return true;
                    }
                    break;
                case KeyEvent.KEYCODE_MEDIA_NEXT:
                    onNextClick();
                    return true;
                case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                    onPreviousClick();
                    return true;
                case KeyEvent.KEYCODE_MEDIA_REWIND:
                    onRewindClick();
                    return true;
                case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
                    onFastForwardClick();
                    return true;
            }
            return false;
        }
@ Override public boolean onKey ( View view , int keyCode , KeyEvent event ) { if ( event . getAction ( ) != KeyEvent . ACTION_DOWN ) { return false ; } switch ( keyCode ) { case KeyEvent . KEYCODE_BACK : if ( isVisible ) { hideDelayed ( 0 ) ; return true ; } break ; case KeyEvent . KEYCODE_DPAD_UP : showTemporary ( ) ; return true ; case KeyEvent . KEYCODE_DPAD_DOWN : hideDelayed ( 0 ) ; return true ; case KeyEvent . KEYCODE_DPAD_LEFT : showTemporary ( ) ; focusPrevious ( currentFocus ) ; return true ; case KeyEvent . KEYCODE_DPAD_RIGHT : showTemporary ( ) ; focusNext ( currentFocus ) ; return true ; case KeyEvent . KEYCODE_DPAD_CENTER : showTemporary ( ) ; currentFocus . callOnClick ( ) ; return true ; case KeyEvent . KEYCODE_MEDIA_PLAY_PAUSE : onPlayPauseClick ( ) ; return true ; case KeyEvent . KEYCODE_MEDIA_PLAY : if ( videoView != null && ! videoView . isPlaying ( ) ) { videoView . start ( ) ; return true ; } break ; case KeyEvent . KEYCODE_MEDIA_PAUSE : if ( videoView != null && videoView . isPlaying ( ) ) { videoView . pause ( ) ; return true ; } break ; case KeyEvent . KEYCODE_MEDIA_NEXT : onNextClick ( ) ; return true ; case KeyEvent . KEYCODE_MEDIA_PREVIOUS : onPreviousClick ( ) ; return true ; case KeyEvent . KEYCODE_MEDIA_REWIND : onRewindClick ( ) ; return true ; case KeyEvent . KEYCODE_MEDIA_FAST_FORWARD : onFastForwardClick ( ) ; return true ; } return false ; }
NOTE: the view is not always the currently focused view, thus the
 {@link #currentFocus} variable
NOTE : the view is not always the currently focused view thus the { @link #currentFocus } variable