Java Code Examples for android.view.KeyEvent#isNumLockOn()

The following examples show how to use android.view.KeyEvent#isNumLockOn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyboardLockMonitor.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyEvent(KeyEvent event, EventId eventId) {
  // Lock state changes should only occur on key up. If we don't check for key up, two events
  // will fire. This is especially noticeable if the user holds down the Caps Lock key for
  // a while before releasing.
  if (event.getAction() == KeyEvent.ACTION_UP) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_CAPS_LOCK) {
      if (event.isCapsLockOn()) {
        compositor.handleEvent(Compositor.EVENT_CAPS_LOCK_ON, eventId);
      } else {
        compositor.handleEvent(Compositor.EVENT_CAPS_LOCK_OFF, eventId);
      }
    } else if (event.getKeyCode() == KeyEvent.KEYCODE_NUM_LOCK) {
      if (event.isNumLockOn()) {
        compositor.handleEvent(Compositor.EVENT_NUM_LOCK_ON, eventId);
      } else {
        compositor.handleEvent(Compositor.EVENT_NUM_LOCK_OFF, eventId);
      }
    } else if (event.getKeyCode() == KeyEvent.KEYCODE_SCROLL_LOCK) {
      if (event.isScrollLockOn()) {
        compositor.handleEvent(Compositor.EVENT_SCROLL_LOCK_ON, eventId);
      } else {
        compositor.handleEvent(Compositor.EVENT_SCROLL_LOCK_OFF, eventId);
      }
    }
  }

  return false; // Never intercept keys; only report on their state.
}
 
Example 2
Source File: KeyNavigationUtil.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the given event is any of DPAD down or NUMPAD down.
 * @param event Event to be checked.
 * @return Whether the event should be processed as a navigation down.
 */
public static boolean isGoDown(KeyEvent event) {
    return isActionDown(event) && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN
            || (!event.isNumLockOn() && event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_2));
}
 
Example 3
Source File: KeyNavigationUtil.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example 4
Source File: KeyNavigationUtil.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example 5
Source File: KeyNavigationUtil.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the given event is any of DPAD down or NUMPAD down.
 * @param event Event to be checked.
 * @return Whether the event should be processed as a navigation down.
 */
public static boolean isGoDown(KeyEvent event) {
    return isActionDown(event) && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN
            || (!event.isNumLockOn() && event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_2));
}
 
Example 6
Source File: KeyNavigationUtil.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example 7
Source File: KeyNavigationUtil.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example 8
Source File: KeyNavigationUtil.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the given event is any of DPAD down or NUMPAD down.
 * @param event Event to be checked.
 * @return Whether the event should be processed as a navigation down.
 */
public static boolean isGoDown(KeyEvent event) {
    return isActionDown(event) && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN
            || (!event.isNumLockOn() && event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_2));
}
 
Example 9
Source File: KeyNavigationUtil.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example 10
Source File: KeyNavigationUtil.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}