diff --git a/profiler/src/BackendEmscripten.cpp b/profiler/src/BackendEmscripten.cpp index e951de2c..d1204d7a 100644 --- a/profiler/src/BackendEmscripten.cpp +++ b/profiler/src/BackendEmscripten.cpp @@ -162,6 +162,15 @@ static ImGuiKey TranslateKeyCode( const char* code ) return ImGuiKey_None; } +static void UpdateKeyModifiers( const EmscriptenKeyboardEvent* e ) +{ + ImGuiIO& io = ImGui::GetIO(); + io.AddKeyEvent( ImGuiMod_Ctrl, e->ctrlKey ); + io.AddKeyEvent( ImGuiMod_Shift, e->shiftKey ); + io.AddKeyEvent( ImGuiMod_Alt, e->altKey ); + io.AddKeyEvent( ImGuiMod_Super, e->metaKey ); +} + Backend::Backend( const char* title, const std::function& redraw, const std::function& scaleChanged, const std::function& isBusy, RunQueue* mainThreadTasks ) { constexpr EGLint eglConfigAttrib[] = { @@ -243,6 +252,7 @@ Backend::Backend( const char* title, const std::function& redraw, const return EM_TRUE; } ); emscripten_set_keydown_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, EM_TRUE, [] ( int, const EmscriptenKeyboardEvent* e, void* ) -> EM_BOOL { + UpdateKeyModifiers( e ); const auto code = TranslateKeyCode( e->code ); if( code == ImGuiKey_None ) return EM_FALSE; ImGui::GetIO().AddKeyEvent( code, true ); @@ -250,6 +260,7 @@ Backend::Backend( const char* title, const std::function& redraw, const return EM_TRUE; } ); emscripten_set_keyup_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, EM_TRUE, [] ( int, const EmscriptenKeyboardEvent* e, void* ) -> EM_BOOL { + UpdateKeyModifiers( e ); const auto code = TranslateKeyCode( e->code ); if( code == ImGuiKey_None ) return EM_FALSE; ImGui::GetIO().AddKeyEvent( code, false );