summaryrefslogtreecommitdiff
path: root/examples/example_06_keyboard_events.nim
blob: ea19404034c0fcb668e3c17a0da6cb370f795c77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# This example shows how to handle keyboard events.

import nigui

app.init()

var window = newWindow()

var label = newLabel()
window.add(label)

window.onKeyDown = proc(event: KeyboardEvent) =
  label.text = label.text & "KeyDown event: key: " & $event.key & ", unicode: " & $event.unicode & ", character: " & event.character & ", down keys: " & $downKeys() & "\n"

  # Ctrl + Q -> Quit application
  if Key_Q.isDown() and Key_ControlL.isDown():
    app.quit()

window.show()

app.run()