Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to trigger a click on a child element? #592

Closed
aalexei opened this issue Nov 15, 2024 · 2 comments
Closed

How to trigger a click on a child element? #592

aalexei opened this issue Nov 15, 2024 · 2 comments

Comments

@aalexei
Copy link

aalexei commented Nov 15, 2024

Hi, I'm trying to add keybindings to a UI, and would like to simulated a mouse click on a child element from the keyboard. Something line
_="on keyup[key=='a'] trigger click on the first <button.yes/> in me"

but this doesn't work. To test, "on keyup[key=='a'] toggle .bg-orange-300 on the first <button.yes/> in me" works fine to change the attribute of the target element, but I want to simulate a click on the element that triggers the existing event handlers exactly like the user had used a mouse. Is this possible?

@aalexei
Copy link
Author

aalexei commented Nov 16, 2024

I can get the effect with
on keyup[key=='a'] get the first <button.yes/> in me then call it.click()

@1cg
Copy link
Contributor

1cg commented Dec 13, 2024

yep, that's reasonable

@1cg 1cg closed this as completed Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants