intrepret Direction Key : Key « User Event « Android

Home
Android
1.2D Graphics
2.Animation
3.Core Class
4.Database
5.Date Type
6.Development
7.File
8.Game
9.Hardware
10.Media
11.Network
12.Security
13.UI
14.User Event
Android » User Event » Key 
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.