pot-desktop icon indicating copy to clipboard operation
pot-desktop copied to clipboard

[BUG]: letter keys do not count as part of a hotkey combination

Open KOCMOTAHK opened this issue 5 months ago • 1 comments

Description

combinations like ctrl+q are not recognized when pressed. numbers, like ctrl+1, work

Image

Image

Reproduction

assign a hotkey containing a letter press the assigned combination under the conditions corresponding to it

Platform

Windows

System Version

Windows 10 Домашняя для одного языка 22H2 19045.5965 Windows Feature Experience Pack 1000.19061.1000.0

Window System (Linux Only)

None

Software Version

3,0,7

Log File

pot.log

Additional Information

After installing the program everything worked, but after closing it broke.

KOCMOTAHK avatar Jun 28 '25 09:06 KOCMOTAHK

The code prevents the default action for all Ctrl+ combinations except for the allowed keys (c, v, x, a, z, y). This means Ctrl+Q is being blocked by e.preventDefault() and will not be recognized by any other handler. But ctrl+1 works because in the code only blocks Ctrl+ combinations if the key is not in the allowKeys array (which only contains some letters). According to me below code can solve this bug

// ... existing code ... useEffect(() => { const handler = async (e) => { // Allow all Ctrl+letter and Ctrl+number shortcuts if (e.ctrlKey && !/^[a-z0-9]$/i.test(e.key)) { e.preventDefault(); } if (devMode !== null && devMode && e.key === 'F12') { await invoke('open_devtools'); } if (e.key.startsWith('F') && e.key.length > 1) { e.preventDefault(); } if (e.key === 'Escape') { await appWindow.close(); } }; document.addEventListener('keydown', handler); return () => document.removeEventListener('keydown', handler); }, [devMode]); // ... existing code ...

Pankajyadav919 avatar Jun 28 '25 16:06 Pankajyadav919

how to remove this?

KOCMOTAHK avatar Jun 29 '25 11:06 KOCMOTAHK

Good Evening Sir , Using below code bug can be remove .If I am wrong please guide me.

Update in app.jsx file useEffect(() => { const handler = async (e) => { const allowedKey = /^[a-z0-9]$/i.test(e.key); if (e.ctrlKey && !allowedKey) { // You can decide to log or prevent based on use-case e.preventDefault(); }

    if (devMode !== null && devMode && e.key === 'F12') {
        await invoke('open_devtools');
    }

    if (e.key.startsWith('F') && e.key.length > 1) {
        e.preventDefault(); // blocks F1, F2, ...
    }

    if (e.key === 'Escape') {
        await appWindow.close();
    }
};

document.addEventListener('keydown', handler);
return () => document.removeEventListener('keydown', handler);

}, [devMode]);

On Sun, Jun 29, 2025 at 4:34 PM KOCMOTAHK @.***> wrote:

KOCMOTAHK left a comment (pot-app/pot-desktop#1136) https://github.com/pot-app/pot-desktop/issues/1136#issuecomment-3016593515

how to remove this?

— Reply to this email directly, view it on GitHub https://github.com/pot-app/pot-desktop/issues/1136#issuecomment-3016593515, or unsubscribe https://github.com/notifications/unsubscribe-auth/BK3YPN7NCJK43CBDWMF5QA33F7B2XAVCNFSM6AAAAACAKWCZ4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMJWGU4TGNJRGU . You are receiving this because you commented.Message ID: @.***>

Pankajyadav919 avatar Jun 29 '25 16:06 Pankajyadav919

and why do I need the code? what should I do with it?

KOCMOTAHK avatar Jun 29 '25 19:06 KOCMOTAHK