about summary refs log tree commit diff stats
path: root/p9c/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'p9c/keyboard.c')
-rw-r--r--p9c/keyboard.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/p9c/keyboard.c b/p9c/keyboard.c
new file mode 100644
index 0000000..175658b
--- /dev/null
+++ b/p9c/keyboard.c
@@ -0,0 +1,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;
+			}
+		}
+	}
+}
\ No newline at end of file