Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Max100's avatar

Listening for keypresses in a vue template

Using inertia/vue, I'm not clear how to listen for key presses for the rendered vue that is not a form.

It looks like I want to use the @keyup or @keydown directive, but I'm not sure where to put that to listen for key presses for the vue.

I've tried using @keypress or @keydown attached to a div in the template, but I doesn't seem to work. How can I listen for keypresses on a template that doesn't have a form?

Thanks

0 likes
2 replies
Max100's avatar

Great, I'll give that a try! Thanks for your reply!

Please or to participate in this conversation.