Genie Discord forum
![Author Avatar](https://cdn.discordapp.com/avatars/679661866166910986/f3ed85f7a3e27b92039307687c03613a.png?size=512)
Is there a way for us to link variables to specific keyboard events?
![Author Avatar](https://cdn.discordapp.com/avatars/679661866166910986/f3ed85f7a3e27b92039307687c03613a.png?size=512)
Does anyone if it's possible?
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
Umm I don't think you can do that with variables, but we do have keyboard event detection
https://learn.genieframework.com/examples/reactive-ui/keypress-detection
![Author Avatar](https://cdn.discordapp.com/avatars/679661866166910986/f3ed85f7a3e27b92039307687c03613a.png?size=512)
I do not know how I managed to miss that in the docs... Thank you! Any way I can have @on("keyup.enter", :keypress)
work on a the whole page rather than just for a textfield
?
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
you can attach events to any component. If you want to do the entire page, wrapt it in a div or something, and attach an event to it like this
using GenieFramework
@app begin
@event :page_clicked begin
println("page clicked")
end
end
ui() = Html.div([h1("here's some text"), h3("and some more")], @on("click", :page_clicked))
@page("/", ui)
![Author Avatar](https://cdn.discordapp.com/avatars/679661866166910986/f3ed85f7a3e27b92039307687c03613a.png?size=512)
This is brilliant!!! Thank you!