microsoft / microsoft/PowerToys
[Peek] Feature Request: Add "Hold-to-Peek" (Spacebar long press) support
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 139k
- Forks
- 8.6k
- PR merge metrics
- PR metrics pending
Description
Description of the new feature / enhancement
I am proposing a new activation mode for the Peek module called "Hold-to-Peek".
Currently, the Spacebar functions as a toggle (press to open, press again to close). I would like to add an option to enable a long-press behavior, where Peek opens the file preview when the Spacebar is held down and automatically closes it as soon as the key is released. This can be implemented as an additional setting, allowing users to toggle between "Toggle Mode" and "Hold-to-Peek Mode".
I have also observed that in the current implementation, holding down the Spacebar triggers the Windows keyboard auto-repeat mechanism. This causes the on_hotkey function to be called repeatedly, leading to the flickering of the Peek window and potential instability in the viewer process. By implementing the "Hold-to-Peek" logic with proper debouncing and key-state monitoring, we can effectively resolve this flickering issue as well, resulting in a much smoother user experience.
Scenario when this would be used?
This feature would be primarily used for "glance-and-dismiss" tasks.
Imagine a user browsing a folder with dozens of images or documents. Instead of pressing the Spacebar twice for every single file (open -> preview -> close), the user could simply hold the Spacebar while navigating through files with arrow keys. Releasing the Spacebar immediately hides the preview. This significantly streamlines the workflow for rapid file inspection and reduces the number of keystrokes needed, providing a more fluid user experience similar to macOS Quick Look.
Supporting information
- Inspiration: This behavior is natively supported in macOS's "Quick Look" feature, which is widely considered a gold standard for file previewing efficiency.
- Technical feasibility: I have conducted preliminary experiments and believe this can be implemented by handling the on_hotkey event. Using an asynchronous background thread to monitor the key state (long-press detection via GetTickCount64 and GetAsyncKeyState) allows us to distinguish between short and long presses without blocking the main UI thread.
- Consistency: This feature aligns with PowerToys' mission to provide productivity-boosting utilities for Windows users.
I am happy to submit a Pull Request if this feature is aligned with the project roadmap.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Peek module's on_hotkey handler and review the proposed GetTickCount64 and GetAsyncKeyState approach for monitoring Spacebar state without blocking the UI. Done means a setting selects Toggle Mode or Hold-to-Peek Mode, key auto-repeat no longer causes flickering, and releasing Spacebar closes the preview reliably.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop, operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100