blob: 175658b0e2051949fd8fd9e5f4cf4c04f0378462 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
#include <keyboard.h>
void
eresized(int new)
{
if(new&& getwindow(display, Refnone) < 0)
sysfatal("can't reattach to window");
}
void
main(int argc, char* argv[])
{
// USED(argc, argv);
Event ev;
int e;
initdraw(0, 0, "Example: Keyboard");
eresized(0);
einit(Ekeyboard);
/* Main loop */
for(;;) {
e = event(&ev);
if(e == Ekeyboard) {
print("key: %d\n", ev.kbdc);
/* Break on escape */
if(ev.kbdc == 27) {
print("Escaped\n");
break;
}
}
}
}
|