Skip to content

Commit

Permalink
detect numpad modifier and add appropriate offset to keycode
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharm committed Nov 7, 2017
1 parent 3121b51 commit 0ad380d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ static uint32_t GetTranslatedKeyCode(const pp::KeyboardInputEvent& event) {
break;
}

// We have to handle the ISKEYPAD modifier on macOS, and convert them
// to the correct numpad keycodes for Windows.
int32_t num = event.GetKeyCode() - 0x30;
if ((event.GetModifiers() & PP_INPUTEVENT_MODIFIER_ISKEYPAD) &&
num >= 0 && num <= 9) {
// Offset with numpad 0's virtual keycode
return num + 0x60;
}

return event.GetKeyCode();
}

Expand Down

0 comments on commit 0ad380d

Please sign in to comment.