vnphanquang / svelte-put

Useful svelte stuff to put in your projects
https://svelte-put.vnphanquang.com
MIT License
836 stars 25 forks source link

shortcut: get keyboard event / actual target #257

Closed vnphanquang closed 11 months ago

vnphanquang commented 11 months ago

Discussed in https://github.com/vnphanquang/svelte-put/discussions/256

Originally posted by **moklick** December 12, 2023 Hey! I am using shortcut for handling several user actions. I bind all handlers on ``. Now I need to filter some events. For example, if I am in an input field, I don't want to trigger the callback. Normally I would just look at the keyboard event and check if `event.target` is an input, but that doesn't work here, because it's always the window itself. Is there any way to find out the actual target or get the keyboard event? Basically like this: https://jsbin.com/rufusujati/4/edit?html,js,console,output