kbar icon indicating copy to clipboard operation
kbar copied to clipboard

Toggle KBar shortcuts when input/textbox is focused

Open notmedia opened this issue 2 years ago • 6 comments

Hi, thank you for this great lib. In my case I have some shortcuts with $mod sequence, like the default KBar $mod+k. When the input or textbox focused this shortcuts are not working because of this function -https://github.com/timc1/kbar/blob/main/src/utils.ts#L101

But the default $mod+k works anyway. Maybe we can add an option for each shortcut which defines is this shortcut ignore on focused elements or not.

notmedia avatar Aug 20 '22 21:08 notmedia

Hey, I created PR for the behavior you described. Also needed such functionality, so maybe we could upvote the issue

https://github.com/timc1/kbar/pull/242

thecoorum avatar Aug 22 '22 20:08 thecoorum

Hm, this is interesting – so when kbar is opened, you want specific shortcuts; ie $mod+p to trigger actions? Once triggered, kbar will then close?

timc1 avatar Aug 25 '22 21:08 timc1

@timc1 Hey! In my case I have code editor input, when this editor is focused I want to toggle kbar shortcuts. Right now only $mod+K works this way (opens default kbar search). But it would be perfect if I could trigger different shortcuts.

#242 adds this functionality, but maybe we can set in kbar options what shortcuts are available from focused inputs (maybe not all $mod+* shortcuts need to handle this way)

notmedia avatar Aug 25 '22 22:08 notmedia

@timc1 by the logic of the kbar we can see that if an action has perform a function then it will close automatically. I can see a few ways of handling shortcuts either by the ability to specify focused elements when shortcuts can or can't be fired or by specifying patterns in which shortcuts can be fired when the kbar is opened

thecoorum avatar Aug 26 '22 07:08 thecoorum

Hey @timc1! Any updates on this?

notmedia avatar Sep 04 '22 13:09 notmedia

@notmedia please see https://github.com/timc1/kbar/pull/242#issuecomment-1236428377 thank you!

timc1 avatar Sep 04 '22 22:09 timc1

Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 03 '22 22:11 stale[bot]