Skip to content

Commit

Permalink
chore(example): fix keyevent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
pierpo committed Oct 31, 2023
1 parent ebae2dd commit b98b7e1
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
// KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);
//
// Using B.
KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);
if (KeyEventModule.getInstance() != null) {
KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);
}

// There are 2 ways this can be done:
// 1. Override the default keyboard event behavior
Expand All @@ -43,7 +45,9 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {

@Override // <--- Add this method if you want to react to keyUp
public boolean onKeyUp(int keyCode, KeyEvent event) {
KeyEventModule.getInstance().onKeyUpEvent(keyCode, event);
if (KeyEventModule.getInstance() != null) {
KeyEventModule.getInstance().onKeyUpEvent(keyCode, event);
}

// There are 2 ways this can be done:
// 1. Override the default keyboard event behavior
Expand Down

0 comments on commit b98b7e1

Please sign in to comment.