# How do I allow onkeydown to handle events?

**URL:** <https://community.aseprite.org/t/how-do-i-allow-onkeydown-to-handle-events/28937>\
**Category:** Help\
**Created:** [October 19, 2026, 1:34am UTC](https://community.aseprite.org/t/how-do-i-allow-onkeydown-to-handle-events/28937 "2026-10-19T01:34:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zander8](https://community.aseprite.org/letter_avatar/zander8/32/6_449c533f586939b6e5f246632a46421f.png) [@Zander8](https://community.aseprite.org/u/Zander8)\
**Post date:** [October 19, 2026, 1:34am UTC](https://community.aseprite.org/t/how-do-i-allow-onkeydown-to-handle-events/28937/1 "2026-10-19T01:34:30Z")

</div>

“If a canvas widget handles these events, it will receive the keyboard focus when it’s clicked.”

I set dialog canvas onkeydown to a function, but it’s not called.  
dialog:canvas{id=“select\_canvas”, width=200,autoscaling=true,onkeydown=select\_canvas\_keydown}

edit2: key presses seem to be handled by aseprite itself and trigger aseprite tools.

edit3: Figured out the problem, I added the canvas to the dialog between two tabs. Putting it after endtabs lets it show up and take key events (but only when it has focus, and it loses focus if a popup happens, like when you print() something).
