You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disable "Home" and "End" keys for selecting items in list #293
Hello, is there a way to disable that the "Home" and "End" jump to the first and last index of the item list? I want to use it to do this in the input and wish to disable this behaviour for the items themselves.
Activity
tobiasSchaathun commentedon Aug 5, 2024
I figured it out, leaving it here if anyone is interested i the answer in the future....
You can add an "onKeyDown" to the Command itself and use event.preventDefault to achieve this :)
skirsten commentedon Sep 7, 2024
Hi, I am running into the same issue. The problem is that with
event.preventDefaultthe input will also not handle the event.What I want is the default functionality: Home goes to beginning of the input text and End to the end of the text. Unfortunately this seems not possible to achieve looking at the code: https://github.com/pacocoursey/cmdk/blob/92344c58a63b995f6eb149245c56ea548540dd18/cmdk/src/index.tsx#L571-L575
kevin-lonestone commentedon Nov 5, 2024
This workaround worked for me: stop the keydown event from propagating from the input.
skirsten commentedon Nov 5, 2024
@kevin-lonestone Awesome workaround. Works perfectly. Thanks a lot! 🎉