mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-22 10:07:37 +00:00
## Summary of the Pull Request Accumulated information from internal transition about the modules development, and reworked it to be added in dev docs. Also the dev docs intself was restructured to be more organized. New pages was verified by transition team. ## PR Checklist - [x] **Dev docs:** Added/updated --------- Co-authored-by: Zhaopeng Wang (from Dev Box) <zhaopengwang@microsoft.com> Co-authored-by: Hao Liu <liuhao3418@gmail.com> Co-authored-by: Peiyao Zhao <105847726+zhaopy536@users.noreply.github.com> Co-authored-by: Mengyuan <162882040+chenmy77@users.noreply.github.com> Co-authored-by: zhaopeng wang <33367956+wang563681252@users.noreply.github.com> Co-authored-by: Jaylyn Barbee <51131738+Jaylyn-Barbee@users.noreply.github.com>
2.2 KiB
2.2 KiB
Custom HotKey Control
The Settings project provides a custom hotkey control which consumes key presses. This control can be used to set the hotkey of any PowerToy.
HotKey Control in FancyZones
Hotkey related files
HotkeySettingsControlHook.cs
- This function initializes and starts the
keyboardHook
for the hotkey control.
public HotkeySettingsControlHook(KeyEvent keyDown, KeyEvent keyUp, IsActive isActive, FilterAccessibleKeyboardEvents filterAccessibleKeyboardEvents)
{
_keyDown = keyDown;
_keyUp = keyUp;
_isActive = isActive;
_filterKeyboardEvent = filterAccessibleKeyboardEvents;
_hook = new KeyboardHook(HotkeySettingsHookCallback, IsActive, FilterKeyboardEvents);
_hook.Start();
}
HotkeySettingsControl.xaml.cs
-
The function of this class is to update the state of the keys being pressed within the custom control. This information is stored in
internalSettings
. -
It provides the following callbacks to the
HotKeySettingsControlHook
:KeyUp
: Resets the key state ininternalSettings
when a key is released.KeyDown
: Updates the user facing text of the hotkey control as soon as a key is pressed.isActive
: Sets the current status of the keyboard hook.FilterAccessibleKeyboardEvents
: This function is used to ignore theTab
andShift+Tab
key presses to meet the accessibility requirements.
HotkeySettings.cs
- Contains the structure of a HotKey where it is represented as a combination of one of the modifier keys (
Alt
,Shift
,Win
andCtrl
) and a non-modifier key.
Note
- The control displays all key presses to the user (except Tab and Shift+Tab which move focus out of the control). However, when the focus is being lost from the control, the
lastValidHotkeySettings
is set as the user facing text.