Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. @Override
  2. public boolean dispatchKeyEvent(@NonNull KeyEvent kEvent) {
  3. final int action = kEvent.getAction();
  4. final int keyCode = kEvent.getKeyCode();
  5. final char character = (char) kEvent.getUnicodeChar();
  6. if (action == KeyEvent.ACTION_UP) {
  7. Log.i(">>>>DEBUG", "KEY EVENT");
  8. final long res = kEvent.getEventTime() - this.timestampLastKeyboardEvent;
  9. switch (keyCode) {
  10. case KeyEvent.KEYCODE_DEL:
  11. // FIXME
  12. this.capuccinoEventLogger.removeLastCharacter();
  13. break;
  14. case KeyEvent.KEYCODE_TAB:
  15. case KeyEvent.KEYCODE_ENTER:
  16. this.capuccinoEventLogger.markLastCapuccinoEventFinal();
  17. break;
  18. default:
  19. // HACK: there is a strange behaviour when a special character is
  20. // typed the current method is invoked twice, one for the normal
  21. // key and the other for the shift + key code.
  22. if (res != 0) {
  23. CapuccinoKeyboardEvent ce = new CapuccinoKeyboardEvent(character);
  24. this.capuccinoEventLogger.addNewCapuccinoEvent(ce);
  25. }
  26. break;
  27. }
  28. this.timestampLastKeyboardEvent = kEvent.getEventTime();
  29. }
  30. return super.dispatchKeyEvent(kEvent);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement