Skip to content

Commit

Permalink
impl: when_some_key_pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 6, 2023
1 parent 027f03a commit 878598c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ export class Entry {
when_run_button_click(f: () => Promise<void>) {
this.on("start", f)
}
when_some_key_pressed(keyCode: string, f: () => Promise<void>) {
document.body.addEventListener("keydown", e => {
if (e.keyCode == Number(keyCode)) {
f()
}
})
}
when_message_cast(messageId: string, f: () => Promise<void>) {
this.on(`message_${messageId}`, f)
}
Expand Down

0 comments on commit 878598c

Please sign in to comment.