From 3f5f37d910a2c8fde3bb5123c9516f5f9e38af2b Mon Sep 17 00:00:00 2001 From: Floris Westerman Date: Tue, 27 Jul 2021 19:11:51 +0200 Subject: [PATCH] Fix: Multimedia Key Hotkey Support (#10801) ## Summary of the Pull Request Fixes/implements #10058 according to directions in that issue: added support for browser navigation keys to be used in actions. ## References ## PR Checklist * [x] Closes #10058 * [x] CLA signed. * [x] Tests added/passed * [x] Documentation updated: . If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: https://github.com/MicrosoftDocs/terminal/pull/371 * [x] Schema updated. * [x] I've discussed this with core contributors already. According to instructions in #10058 ## Detailed Description of the Pull Request / Additional comments The mouse back/forward keys do not correspond to the keys added here. That would be a nice (but more complicated) addition, I'll add an issue for it. --- doc/cascadia/profiles.schema.json | 2 +- .../TerminalSettingsModel/KeyChordSerialization.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index e2cf5d71cbb..96e7c6cfce8 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -4,7 +4,7 @@ "title": "Microsoft's Windows Terminal Settings Profile Schema", "definitions": { "KeyChordSegment": { - "pattern": "^(?:(?:ctrl|alt|shift|win)\\+)*(?:app|backspace|comma|delete|down|end|enter|esc|escape|home|insert|left|menu|minus|pagedown|pageup|period|pgdn|pgup|plus|right|space|tab|up|f(?:1\\d?|2[0-4]?|[3-9])|numpad\\d|numpad_(?:\\d|add|decimal|divide|minus|multiply|period|plus|subtract)|(?:vk|sc)\\((?:[1-9]|1?\\d{2}|2[0-4]\\d|25[0-5])\\)|[^\\s+])(?:\\+(?:ctrl|alt|shift|win))*$", + "pattern": "^(?:(?:ctrl|alt|shift|win)\\+)*(?:app|backspace|browser_(?:back|forward|refresh|stop|search|favorites|home)|comma|delete|down|end|enter|esc|escape|home|insert|left|menu|minus|pagedown|pageup|period|pgdn|pgup|plus|right|space|tab|up|f(?:1\\d?|2[0-4]?|[3-9])|numpad\\d|numpad_(?:\\d|add|decimal|divide|minus|multiply|period|plus|subtract)|(?:vk|sc)\\((?:[1-9]|1?\\d{2}|2[0-4]\\d|25[0-5])\\)|[^\\s+])(?:\\+(?:ctrl|alt|shift|win))*$", "type": "string", "description": "The string should fit the format \"[ctrl+][alt+][shift+][win+]\", where each modifier is optional. KeyName is either any single key character, an explicit virtual key or scan code in the form vk(nnn) and sc(nnn) respectively, or one of the special names listed at https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#accepted-modifiers-and-keys" }, diff --git a/src/cascadia/TerminalSettingsModel/KeyChordSerialization.cpp b/src/cascadia/TerminalSettingsModel/KeyChordSerialization.cpp index 8e0b7162f4f..378f92bde36 100644 --- a/src/cascadia/TerminalSettingsModel/KeyChordSerialization.cpp +++ b/src/cascadia/TerminalSettingsModel/KeyChordSerialization.cpp @@ -78,7 +78,14 @@ constexpr std::wstring_view WIN_KEY{ L"win" }; XX(VK_OEM_PLUS, L"plus") /* '+' any country */ \ XX(VK_OEM_COMMA, L"comma") /* ',' any country */ \ XX(VK_OEM_MINUS, L"minus") /* '-' any country */ \ - XX(VK_OEM_PERIOD, L"period") /* '.' any country */ + XX(VK_OEM_PERIOD, L"period") /* '.' any country */ \ + XX(VK_BROWSER_BACK, L"browser_back") \ + XX(VK_BROWSER_FORWARD, L"browser_forward") \ + XX(VK_BROWSER_REFRESH, L"browser_refresh") \ + XX(VK_BROWSER_STOP, L"browser_stop") \ + XX(VK_BROWSER_SEARCH, L"browser_search") \ + XX(VK_BROWSER_FAVORITES, L"browser_favorites") \ + XX(VK_BROWSER_HOME, L"browser_home") constexpr std::wstring_view vkeyPrefix{ L"vk(" }; constexpr std::wstring_view scanCodePrefix{ L"sc(" };