Java Code Examples for android.view.KeyEvent#KEYCODE_W

The following examples show how to use android.view.KeyEvent#KEYCODE_W . 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: GUIListeners.java    From Beats with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static public int keyCode2Direction(int keyCode) {
	/* interprets a keyCode as a direction
	 * input:   keyCode  - a key code passed to handler           
	 * output: [0 1 2 3] -> [left down up right]; -1 -> unknown
	 */
	switch (keyCode) {
	// WASD, ZX-NM spread, AS-KL spread
	// 12-90 spread, D-Pad
	// Headphone music controller
	case KeyEvent.KEYCODE_A: case KeyEvent.KEYCODE_Z:
	case KeyEvent.KEYCODE_1: case KeyEvent.KEYCODE_DPAD_LEFT:
	case KeyEvent.KEYCODE_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_REWIND:
	case KeyEvent.KEYCODE_BUTTON_X:
		return 0;
	case KeyEvent.KEYCODE_S: case KeyEvent.KEYCODE_X:
	case KeyEvent.KEYCODE_2: case KeyEvent.KEYCODE_DPAD_DOWN:
	case KeyEvent.KEYCODE_MEDIA_STOP:
	case KeyEvent.KEYCODE_BUTTON_A:
		return 1;
	case KeyEvent.KEYCODE_W: case KeyEvent.KEYCODE_N: case KeyEvent.KEYCODE_K:
	case KeyEvent.KEYCODE_9: case KeyEvent.KEYCODE_DPAD_UP:
	case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
	case KeyEvent.KEYCODE_BUTTON_Y:
		return 2;
	case KeyEvent.KEYCODE_D: case KeyEvent.KEYCODE_M: case KeyEvent.KEYCODE_L:
	case KeyEvent.KEYCODE_0: case KeyEvent.KEYCODE_DPAD_RIGHT:
	case KeyEvent.KEYCODE_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
	case KeyEvent.KEYCODE_BUTTON_B:
		return 3;
	default:
		return -1;
	}
}
 
Example 2
Source File: ContentViewClient.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean shouldOverrideKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    // We need to send almost every key to WebKit. However:
    // 1. We don't want to block the device on the renderer for
    // some keys like menu, home, call.
    // 2. There are no WebKit equivalents for some of these keys
    // (see app/keyboard_codes_win.h)
    // Note that these are not the same set as KeyEvent.isSystemKey:
    // for instance, AKEYCODE_MEDIA_* will be dispatched to webkit.
    if (keyCode == KeyEvent.KEYCODE_MENU ||
        keyCode == KeyEvent.KEYCODE_HOME ||
        keyCode == KeyEvent.KEYCODE_BACK ||
        keyCode == KeyEvent.KEYCODE_CALL ||
        keyCode == KeyEvent.KEYCODE_ENDCALL ||
        keyCode == KeyEvent.KEYCODE_POWER ||
        keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
        keyCode == KeyEvent.KEYCODE_CAMERA ||
        keyCode == KeyEvent.KEYCODE_FOCUS ||
        keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
        keyCode == KeyEvent.KEYCODE_VOLUME_MUTE ||
        keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        return true;
    }

    // We also have to intercept some shortcuts before we send them to the ContentView.
    if (event.isCtrlPressed() && (
            keyCode == KeyEvent.KEYCODE_TAB ||
            keyCode == KeyEvent.KEYCODE_W ||
            keyCode == KeyEvent.KEYCODE_F4)) {
        return true;
    }

    return false;
}
 
Example 3
Source File: ContentViewClient.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean shouldOverrideKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    // We need to send almost every key to WebKit. However:
    // 1. We don't want to block the device on the renderer for
    // some keys like menu, home, call.
    // 2. There are no WebKit equivalents for some of these keys
    // (see app/keyboard_codes_win.h)
    // Note that these are not the same set as KeyEvent.isSystemKey:
    // for instance, AKEYCODE_MEDIA_* will be dispatched to webkit.
    if (keyCode == KeyEvent.KEYCODE_MENU ||
        keyCode == KeyEvent.KEYCODE_HOME ||
        keyCode == KeyEvent.KEYCODE_BACK ||
        keyCode == KeyEvent.KEYCODE_CALL ||
        keyCode == KeyEvent.KEYCODE_ENDCALL ||
        keyCode == KeyEvent.KEYCODE_POWER ||
        keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
        keyCode == KeyEvent.KEYCODE_CAMERA ||
        keyCode == KeyEvent.KEYCODE_FOCUS ||
        keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
        keyCode == KeyEvent.KEYCODE_VOLUME_MUTE ||
        keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        return true;
    }

    // We also have to intercept some shortcuts before we send them to the ContentView.
    if (event.isCtrlPressed() && (
            keyCode == KeyEvent.KEYCODE_TAB ||
            keyCode == KeyEvent.KEYCODE_W ||
            keyCode == KeyEvent.KEYCODE_F4)) {
        return true;
    }

    return false;
}