Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean dispatchKeyEvent(@NonNull KeyEvent kEvent) {
- final int action = kEvent.getAction();
- final int keyCode = kEvent.getKeyCode();
- final char character = (char) kEvent.getUnicodeChar();
- if (action == KeyEvent.ACTION_UP) {
- Log.i(">>>>DEBUG", "KEY EVENT");
- final long res = kEvent.getEventTime() - this.timestampLastKeyboardEvent;
- switch (keyCode) {
- case KeyEvent.KEYCODE_DEL:
- // FIXME
- this.capuccinoEventLogger.removeLastCharacter();
- break;
- case KeyEvent.KEYCODE_TAB:
- case KeyEvent.KEYCODE_ENTER:
- this.capuccinoEventLogger.markLastCapuccinoEventFinal();
- break;
- default:
- // HACK: there is a strange behaviour when a special character is
- // typed the current method is invoked twice, one for the normal
- // key and the other for the shift + key code.
- if (res != 0) {
- CapuccinoKeyboardEvent ce = new CapuccinoKeyboardEvent(character);
- this.capuccinoEventLogger.addNewCapuccinoEvent(ce);
- }
- break;
- }
- this.timestampLastKeyboardEvent = kEvent.getEventTime();
- }
- return super.dispatchKeyEvent(kEvent);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement