From b1f09524c9b31a5eab89f6b40371427d9f4e526e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 1 Jan 2025 11:17:21 +0800 Subject: [PATCH] bugfix --- bricks/keypress.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bricks/keypress.js diff --git a/bricks/keypress.js b/bricks/keypress.js new file mode 100644 index 0000000..90b19ef --- /dev/null +++ b/bricks/keypress.js @@ -0,0 +1,17 @@ +var bricks = window.bricks || {}; + +bricks.KeyTest = class extends bricks.VBox { + constructor(opts){ + super(opts); + bricks.app.bind('keydown', this.key_handler.bind(this)); + } + key_handler(event){ + var key = event.key; + this.clear_widgets(); + var w = new bricks.Text({text:'key press is:' + key}); + this.add_widget(w) + } +} + +bricks.Factory.register('KeyPress', bricks.KeyPress); +