diff --git a/client/eventsSDL/InputSourceKeyboard.cpp b/client/eventsSDL/InputSourceKeyboard.cpp index 96c6d9aea..1ba1a3020 100644 --- a/client/eventsSDL/InputSourceKeyboard.cpp +++ b/client/eventsSDL/InputSourceKeyboard.cpp @@ -32,9 +32,24 @@ InputSourceKeyboard::InputSourceKeyboard() #endif } +std::string InputSourceKeyboard::getKeyNameWithModifiers(const std::string & keyName) const +{ + std::string result; + + if (isKeyboardCtrlDown()) + result += "Ctrl+"; + if (isKeyboardAltDown()) + result += "Alt+"; + if (isKeyboardShiftDown()) + result += "Shift+"; + result += keyName; + + return result; +} + void InputSourceKeyboard::handleEventKeyDown(const SDL_KeyboardEvent & key) { - std::string keyName = SDL_GetKeyName(key.keysym.sym); + std::string keyName = getKeyNameWithModifiers(SDL_GetKeyName(key.keysym.sym)); logGlobal->trace("keyboard: key '%s' pressed", keyName); assert(key.state == SDL_PRESSED); diff --git a/client/eventsSDL/InputSourceKeyboard.h b/client/eventsSDL/InputSourceKeyboard.h index 775318701..7b64f1158 100644 --- a/client/eventsSDL/InputSourceKeyboard.h +++ b/client/eventsSDL/InputSourceKeyboard.h @@ -15,6 +15,7 @@ struct SDL_KeyboardEvent; /// Class that handles keyboard input from SDL events class InputSourceKeyboard { + std::string getKeyNameWithModifiers(const std::string & keyName) const; public: InputSourceKeyboard(); diff --git a/config/shortcutsConfig.json b/config/shortcutsConfig.json index 7dffd4f68..75dc79a19 100644 --- a/config/shortcutsConfig.json +++ b/config/shortcutsConfig.json @@ -4,6 +4,7 @@ // For players (Linux): create file ~/.config/vcmi/shortcutsConfig.json (or ~/.var/app/eu.vcmi.VCMI/config for Flatpak) to modify this set // // When creating your own config, you can remove all hotkeys that you have not changed and game will read them from this file +// It is possible to add modifiers to keys: Ctrl, Shift, or Alt. For example, "Ctrl+Tab" hotkey will only activate if Ctrl is pressed { "keyboard" : { "globalAccept": [ "Return", "Keypad Enter"], @@ -112,6 +113,10 @@ "battleTacticsEnd": [ "Return", "Keypad Enter"], "battleToggleHeroesStats": [], "battleSelectAction": "S", + "lobbyActivateInterface": "Ctrl+Tab", + "spectateTrackHero": "F5", + "spectateSkipBattle": "F7", + "spectateSkipBattleResult": "F8", "townOpenTavern": "T", "townSwapArmies": "Space", "recruitmentMax": "End",