fad0'/>
about summary refs log blame commit diff stats
path: root/p9c/scratch/keyboard.c
blob: 175658b0e2051949fd8fd9e5f4cf4c04f0378462 (plain) (tree)




































                                                     
#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;
			}
		}
	}
}