Example usage for android.view KeyEvent KEYCODE_F5

List of usage examples for android.view KeyEvent KEYCODE_F5

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_F5.

Prototype

int KEYCODE_F5

To view the source code for android.view KeyEvent KEYCODE_F5.

Click Source Link

Document

Key code constant: F5 key.

Usage

From source file:website.openeng.anki.Reviewer.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    char keyPressed = (char) event.getUnicodeChar();
    if (mAnswerField != null && !mAnswerField.isFocused()) {
        if (sDisplayAnswer) {
            if (keyPressed == '1') {
                answerCard(EASE_1);//from   w ww .java2 s  . co  m
                return true;
            }
            if (keyPressed == '2') {
                answerCard(EASE_2);
                return true;
            }
            if (keyPressed == '3') {
                answerCard(EASE_3);
                return true;
            }
            if (keyPressed == '4') {
                answerCard(EASE_4);
                return true;
            }
            if (keyCode == KeyEvent.KEYCODE_SPACE || keyCode == KeyEvent.KEYCODE_ENTER
                    || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) {
                answerCard(getDefaultEase());
                return true;
            }
        }
        if (keyPressed == 'e') {
            editCard();
            return true;
        }
        if (keyPressed == '*') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_MARK_CARD, mMarkCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 0));
            return true;
        }
        if (keyPressed == '-') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 4));
            return true;
        }
        if (keyPressed == '=') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 0));
            return true;
        }
        if (keyPressed == '@') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 1));
            return true;
        }
        if (keyPressed == '!') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 2));
            return true;
        }
        if (keyPressed == 'r' || keyCode == KeyEvent.KEYCODE_F5) {
            playSounds(true);
            return true;
        }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.ichi2.anki.Reviewer.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    char keyPressed = (char) event.getUnicodeChar();
    if (mAnswerField != null && !mAnswerField.isFocused()) {
        if (sDisplayAnswer) {
            if (keyPressed == '1') {
                answerCard(EASE_1);/*from  w  w w.ja  v a 2 s  . com*/
                return true;
            }
            if (keyPressed == '2') {
                answerCard(EASE_2);
                return true;
            }
            if (keyPressed == '3') {
                answerCard(EASE_3);
                return true;
            }
            if (keyPressed == '4') {
                answerCard(EASE_4);
                return true;
            }
            if (keyCode == KeyEvent.KEYCODE_SPACE || keyCode == KeyEvent.KEYCODE_ENTER
                    || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) {
                answerCard(getDefaultEase());
                return true;
            }
        }
        if (keyPressed == 'e') {
            editCard();
            return true;
        }
        if (keyPressed == '*') {
            onMark(mCurrentCard);
            refreshActionBar();
            return true;
        }
        if (keyPressed == '-') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 4));
            return true;
        }
        if (keyPressed == '=') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 0));
            return true;
        }
        if (keyPressed == '@') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 1));
            return true;
        }
        if (keyPressed == '!') {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler,
                    new DeckTask.TaskData(mCurrentCard, 2));
            return true;
        }
        if (keyPressed == 'r' || keyCode == KeyEvent.KEYCODE_F5) {
            playSounds(true);
            return true;
        }

        // different from Anki Desktop
        if (keyPressed == 'z') {
            undo();
            return true;
        }
    }
    return super.onKeyUp(keyCode, event);
}