Code example for KeyEvent

Methods: getActiongetKeyCode

0
        } 
        return super.dispatchKeyEvent(event);
    } 
 
    private boolean shouldEventKeepScreenOnWhileKeyguardShowing(KeyEvent event) {
        if (event.getAction() != KeyEvent.ACTION_DOWN) {
            return false; 
        } 
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_DOWN:
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT:
            case KeyEvent.KEYCODE_DPAD_UP:
                return false; 
            default: 
                return true; 
        } 
    } 
 
    /** 
     * Allows the media keys to work when the keyguard is showing.