Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.view.KeyEvent;

public class Main {
    public static int lookupKeycode(boolean shiftDown, int keycode) {
        switch (keycode) {
        // case KeyEvent.KEYCODE_SHIFT_LEFT: return 0x00;
        // case KeyEvent.KEYCODE_SHIFT_RIGHT: return 0x00;
        case KeyEvent.KEYCODE_0:
            return shiftDown ? 0x126 : 0x27;
        case KeyEvent.KEYCODE_1:
            return 0x30;
        case KeyEvent.KEYCODE_2:
            return 0x31;
        case KeyEvent.KEYCODE_3:
            return 0x11;
        case KeyEvent.KEYCODE_4:
            return 0x12;
        case KeyEvent.KEYCODE_5:
            return 0x13;
        case KeyEvent.KEYCODE_6:
            return 0x34;
        case KeyEvent.KEYCODE_7:
            return shiftDown ? 0x134 : 0x24;
        case KeyEvent.KEYCODE_8:
            return 0x15;
        case KeyEvent.KEYCODE_9:
            return shiftDown ? 0x115 : 0x26;
        case KeyEvent.KEYCODE_A:
            return 0x41;
        case KeyEvent.KEYCODE_B:
            return 0x64;
        case KeyEvent.KEYCODE_C:
            return 0x52;
        case KeyEvent.KEYCODE_D:
            return 0x32;
        case KeyEvent.KEYCODE_E:
            return 0x22;
        case KeyEvent.KEYCODE_F:
            return 0x43;
        case KeyEvent.KEYCODE_G:
            return 0x53;
        case KeyEvent.KEYCODE_H:
            return 0x54;
        case KeyEvent.KEYCODE_I:
            return 0x25;
        case KeyEvent.KEYCODE_J:
            return 0x45;
        case KeyEvent.KEYCODE_K:
            return 0x46;
        case KeyEvent.KEYCODE_L:
            return 0x56;
        case KeyEvent.KEYCODE_M:
            return 0x65;
        case KeyEvent.KEYCODE_N:
            return 0x55;
        case KeyEvent.KEYCODE_O:
            return 0x36;
        case KeyEvent.KEYCODE_P:
            return 0x37;
        case KeyEvent.KEYCODE_Q:
            return 0x10;
        case KeyEvent.KEYCODE_R:
            return 0x33;
        case KeyEvent.KEYCODE_S:
            return 0x51;
        case KeyEvent.KEYCODE_T:
            return 0x23;
        case KeyEvent.KEYCODE_U:
            return 0x35;
        case KeyEvent.KEYCODE_V:
            return 0x63;
        case KeyEvent.KEYCODE_W:
            return 0x21;
        case KeyEvent.KEYCODE_X:
            return 0x42;
        case KeyEvent.KEYCODE_Y:
            return 0x44;
        case KeyEvent.KEYCODE_Z:
            return 0x61;
        case KeyEvent.KEYCODE_SPACE:
            return 0x62;
        case KeyEvent.KEYCODE_ENTER:
            return 0x49;
        case KeyEvent.KEYCODE_DEL:
            return 0x59;
        case KeyEvent.KEYCODE_APOSTROPHE:
            return shiftDown ? 0x31 : 0x124;
        case KeyEvent.KEYCODE_POUND:
            return 0x111; // '#' is Shift+3
        case KeyEvent.KEYCODE_MINUS:
            return shiftDown ? 0x238 : 0x17;
        case KeyEvent.KEYCODE_EQUALS:
            return 0x117;
        case KeyEvent.KEYCODE_AT:
            return 0x47;
        case KeyEvent.KEYCODE_STAR:
            return 0x148;
        case KeyEvent.KEYCODE_PERIOD:
            return shiftDown ? 0x248 : 0x67;
        case KeyEvent.KEYCODE_SEMICOLON:
            return 0x57;
        case KeyEvent.KEYCODE_SLASH:
            return 0x68;
        case KeyEvent.KEYCODE_PLUS:
            return 0x157;
        case KeyEvent.KEYCODE_COMMA:
            return 0x66;
        // case KeyEvent.KEYCODE_GRAVE: return 0x??;
        // case KeyEvent.KEYCODE_LEFT_BRACKET: return 0x??;
        // case KeyEvent.KEYCODE_RIGHT_BRACKET: return 0x??;
        }
        return 0xaa;
    }
}