doc/devdocs/modules/keyboardmanager/debug.md
This document provides guidance on debugging the Keyboard Manager module in PowerToys.
Keyboard Manager consists of two main components:
PowerToys.slnx in Visual StudioKeyboardManagerEditor projectBreakpoints to consider:
EditKeyboardWindow.cpp: CreateWindow() methodEditShortcutsWindow.cpp: CreateWindow() methodWhen debugging configuration changes:
KeyboardManagerState.cpp around the SetRemappedKeys() or SetRemappedShortcuts() methodsThe KeyboardManagerEditorTest project contains tests for the UI functionality. Run these tests to validate UI changes.
KeyboardManagerEngine projectThe keyboard event processing follows this sequence:
KeyboardEventHandlers.cpp processes the eventKeyboardManager.cpp applies remapping logicmain.cpp: StartLowlevelKeyboardHook() - Hook initializationKeyboardEventHandlers.cpp: HandleKeyboardEvent() - Entry point for each keyboard eventKeyboardManager.cpp: HandleKeyEvent() - Processing individual key eventsKeyboardManager.cpp: HandleShortcutRemapEvent() - Processing shortcut remappingEnable detailed logging by setting the _DEBUG and KBM_VERBOSE_LOGGING preprocessor definitions.
If you encounter issues with multiple instances, check the mutex logic in KeyboardManagerEditor.cpp. The editor uses PowerToys_KBMEditor_InstanceMutex to ensure single instance.
To debug both the Editor and Engine: