Merge pull request #348 from kevincharm/fix/macos-numpad

Handle numpad correctly for macOS client
This commit is contained in:
Cameron Gutman 2017-11-07 00:51:28 -08:00 committed by GitHub
commit 8dcd65786e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,6 +99,15 @@ static uint32_t GetTranslatedKeyCode(const pp::KeyboardInputEvent& event) {
break; 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(); return event.GetKeyCode();
} }