Repository: microsoft/PowerToys
File: src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp (C++)

Code before:
                    {
                        std::vector<DWORD> shortcutKeys = std::get<Shortcut>(it->second).GetKeyCodes();
                        for (auto& itSk : shortcutKeys)
                        {
                            ResetIfModifierKeyForLowerLevelKeyHandlers(ii, itSk, it->first);
                        }
                    }

                    // Send daily telemetry event for Keyboard Manager key activation.
                    if (remapToKey)
                    {
                        static int dayWeLastSentKeyToKeyTelemetryOn = -1;
                        auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
                        if (dayWeLastSentKeyToKeyTelemetryOn != currentDay)
                        {
                            Trace::DailyKeyToKeyRemapInvoked();
                            dayWeLastSentKeyToKeyTelemetryOn = currentDay;
                        }
                    }
                    else
                    {
                        static int dayWeLastSentKeyToShortcutTelemetryOn = -1;
                        auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
                        if (dayWeLastSentKeyToShortcutTelemetryOn != currentDay)
                        {
                            Trace::DailyKeyToKeyRemapInvoked();
                            dayWeLastSentKeyToShortcutTelemetryOn = currentDay;
                        }
                    }
                }

                return 1;
            }
        }

        return 0;
    }

    /* This feature has not been enabled (code from proof of concept stage)
    * 
    // Function to a change a key's behavior from toggle to modifier
    __declspec(dllexport) intptr_t HandleSingleKeyToggleToModEvent(InputInterface& ii, LowlevelKeyboardEvent* data, State& State) noexcept
    {
        // Check if the key event was generated by KeyboardManager to avoid remapping events generated by us.
        if (!(data->lParam->dwExtraInfo & CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG))
        {
            // The mutex should be unlocked before SendInput is called to avoid re-entry into the same mutex. More details can be found at https://github.com/microsoft/PowerToys/pull/1789#issuecomment-607555837
            std::unique_lock<std::mutex> lock(State.singleKeyToggleToMod_mutex);
            auto it = State.singleKeyToggleToMod.find(data->lParam->vkCode);
            if (it != State.singleKeyToggleToMod.end())
            {

Review comment (suggestion):
```suggestion
                            Trace::DailyKeyToShortcutRemapInvoked();
```

Code after:
                    {
                        std::vector<DWORD> shortcutKeys = std::get<Shortcut>(it->second).GetKeyCodes();
                        for (auto& itSk : shortcutKeys)
                        {
                            ResetIfModifierKeyForLowerLevelKeyHandlers(ii, itSk, it->first);
                        }
                    }

                    // Send daily telemetry event for Keyboard Manager key activation.
                    if (remapToKey)
                    {
                        static int dayWeLastSentKeyToKeyTelemetryOn = -1;
                        auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
                        if (dayWeLastSentKeyToKeyTelemetryOn != currentDay)
                        {
                            Trace::DailyKeyToKeyRemapInvoked();
                            dayWeLastSentKeyToKeyTelemetryOn = currentDay;
                        }
                    }
                    else
                    {
                        static int dayWeLastSentKeyToShortcutTelemetryOn = -1;
                        auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
                        if (dayWeLastSentKeyToShortcutTelemetryOn != currentDay)
                        {
                            Trace::DailyKeyToShortcutRemapInvoked();
                            dayWeLastSentKeyToShortcutTelemetryOn = currentDay;
                        }
                    }
                }

                return 1;
            }
        }

        return 0;
    }

    /* This feature has not been enabled (code from proof of concept stage)
    * 
    // Function to a change a key's behavior from toggle to modifier
    __declspec(dllexport) intptr_t HandleSingleKeyToggleToModEvent(InputInterface& ii, LowlevelKeyboardEvent* data, State& State) noexcept
    {
        // Check if the key event was generated by KeyboardManager to avoid remapping events generated by us.
        if (!(data->lParam->dwExtraInfo & CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG))
        {
            // The mutex should be unlocked before SendInput is called to avoid re-entry into the same mutex. More details can be found at https://github.com/microsoft/PowerToys/pull/1789#issuecomment-607555837
            std::unique_lock<std::mutex> lock(State.singleKeyToggleToMod_mutex);
            auto it = State.singleKeyToggleToMod.find(data->lParam->vkCode);
            if (it != State.singleKeyToggleToMod.end())
            {