Checks whether the given Key event is any of DPAD right or NUMPAD right. - Android User Interface

Android examples for User Interface:Key Event

Description

Checks whether the given Key event is any of DPAD right or NUMPAD right.

Demo Code

// Copyright 2012 The Chromium Authors. All rights reserved.
//package com.java2s;
import android.view.KeyEvent;

public class Main {
    /**/* w ww. jav a 2 s.  com*/
     * Checks whether the given event is any of DPAD right or NUMPAD right.
     * @param event Event to be checked.
     * @return Whether the event should be processed as a navigation right.
     */
    public static boolean isGoRight(KeyEvent event) {
        return isActionDown(event)
                && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT || (!event
                        .isNumLockOn() && event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_6));
    }

    /**
     * Checks whether the given event is an ACTION_DOWN event.
     * @param event Event to be checked.
     * @return Whether the event is an ACTION_DOWN event.
     */
    public static boolean isActionDown(KeyEvent event) {
        return event.getAction() == KeyEvent.ACTION_DOWN;
    }
}

Related Tutorials