intrepret Direction Key : Key « User Event « Android






intrepret Direction Key

    

import android.view.KeyEvent;

 class KeyUtils {
  private KeyUtils() {}
  
  public static int intrepretDirection(int code) {
    switch(code) {
    case KeyEvent.KEYCODE_LEFT_BRACKET:
    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_1:
    case KeyEvent.KEYCODE_4:
    case KeyEvent.KEYCODE_7:
      return KeyEvent.KEYCODE_DPAD_LEFT;
      
    case KeyEvent.KEYCODE_RIGHT_BRACKET:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
    case KeyEvent.KEYCODE_3:
    case KeyEvent.KEYCODE_6:
    case KeyEvent.KEYCODE_9:
      return KeyEvent.KEYCODE_DPAD_RIGHT;
    }
    
    return code;
  }
}

   
    
    
    
  








Related examples in the same category

1.Key event listener
2.Example of writing an input method for a soft keyboard.
3.Soft keyboard get Char
4.show hide virtual keyboard
5.has Physical Keyboard
6.Show Keyboard
7.Hide Keyboard