Fix : Override browser default shortcuts on Linux/Windows system #8

Merged
Yehowshua merged 3 commits from fix-ctrl-l into main 2025-02-02 21:02:20 +00:00
Collaborator

Ctrl + l is needed to clear terminal output instead of accessing bar which is the browser's default behaviour for the shortcut. By enabling preventDefault() prevents default case here.

This PR fixes this.

            const allowedKeys = ["l"];
            document.addEventListener("keydown", (event) => {
                if (
                    event.ctrlKey &&
                    allowedKeys.includes(event.key.toLowerCase())
                ) {
                    event.preventDefault();
                }
            });
`Ctrl + l` is needed to clear terminal output instead of accessing bar which is the browser's default behaviour for the shortcut. By enabling `preventDefault()` prevents default case here. This PR fixes this. ``` const allowedKeys = ["l"]; document.addEventListener("keydown", (event) => { if ( event.ctrlKey && allowedKeys.includes(event.key.toLowerCase()) ) { event.preventDefault(); } }); ```
azkarim added 1 commit 2025-01-31 14:58:51 +00:00
azkarim changed title from Fix : Make `Ctrl + l` work on Linux/Windows system to Fix : `Ctrl + l` to clear terminal output instead of address bar access on Linux/Windows system 2025-01-31 14:59:26 +00:00
azkarim requested review from Yehowshua 2025-01-31 14:59:55 +00:00
azkarim requested review from Artturin 2025-01-31 14:59:55 +00:00
Author
Collaborator

@Artturin @Yehowshua Can you test this on Linux/Windows system?

@Artturin @Yehowshua Can you test this on Linux/Windows system?
azkarim added 1 commit 2025-01-31 15:02:59 +00:00
Owner

The fix works on Linux!!

The fix works on Linux!!
Owner

Can you please modify code to also handle tab keys - and then we're good!

Can you please modify code to also handle tab keys - and then we're good!
azkarim changed title from Fix : `Ctrl + l` to clear terminal output instead of address bar access on Linux/Windows system to Fix : Override browser default shortcuts on Linux/Windows system 2025-01-31 15:05:11 +00:00
azkarim added 1 commit 2025-01-31 15:11:55 +00:00
Yehowshua merged commit 919c1772e7 into main 2025-02-02 21:02:20 +00:00
Yehowshua deleted branch fix-ctrl-l 2025-02-02 21:02:24 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ReferenceProjects/example-spa-elm-app#8
No description provided.