about summary refs log tree commit diff stats
path: root/p9c/scratch/keyboard.c
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2023-05-25 22:04:42 -0400
committerelioat <elioat@tilde.institute>2023-05-25 22:04:42 -0400
commit9d9ec8ce5fef38f991f3a5a708d985b0f5225baa (patch)
tree9c7c69f3efb0db15c3579766e075e9461c3df099 /p9c/scratch/keyboard.c
parente85017e9cecfd5c41b9c9924a9355cad364c0b3e (diff)
downloadtour-9d9ec8ce5fef38f991f3a5a708d985b0f5225baa.tar.gz
*
Diffstat (limited to 'p9c/scratch/keyboard.c')
-rw-r--r--p9c/scratch/keyboard.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/p9c/scratch/keyboard.c b/p9c/scratch/keyboard.c
new file mode 100644
index 0000000..175658b
--- /dev/null
+++ b/p9c/scratch/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