Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import android.view.KeyEvent; public class Main { /** * Checks whether the given event is any of DPAD up or NUMPAD up. * @param event Event to be checked. * @return Whether the event should be processed as a navigation up. */ public static boolean isGoUp(KeyEvent event) { return isActionDown(event) && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP || (!event.isNumLockOn() && event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_8)); } /** * 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; } }