Index: uspace/app/gfxdemo/gfxdemo.c
===================================================================
--- uspace/app/gfxdemo/gfxdemo.c	(revision 587b4cb24eec8f9acd895b16804e0b8dfd437506)
+++ uspace/app/gfxdemo/gfxdemo.c	(revision bac129a9075604499c19f8c8741603fd3bbdaf77)
@@ -44,7 +44,16 @@
 #include <io/console.h>
 #include <io/pixelmap.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <str.h>
 #include <window.h>
+
+static void wnd_kbd_event(void *, kbd_event_t *);
+
+static display_wnd_cb_t wnd_cb = {
+	.kbd_event = wnd_kbd_event
+};
+
+static bool quit = false;
 
 /** Clear screen.
@@ -126,4 +135,7 @@
 
 		fibril_usleep(500 * 1000);
+
+		if (quit)
+			break;
 	}
 
@@ -245,4 +257,7 @@
 				goto error;
 			fibril_usleep(250 * 1000);
+
+			if (quit)
+				break;
 		}
 	}
@@ -298,4 +313,7 @@
 
 		fibril_usleep(500 * 1000);
+
+		if (quit)
+			break;
 	}
 
@@ -318,5 +336,5 @@
 	errno_t rc;
 
-	while (true) {
+	while (!quit) {
 		rc = demo_rects(gc, w, h);
 		if (rc != EOK)
@@ -331,4 +349,6 @@
 			return rc;
 	}
+
+	return EOK;
 }
 
@@ -444,5 +464,5 @@
 	}
 
-	rc = display_window_create(display, &window);
+	rc = display_window_create(display, &wnd_cb, NULL, &window);
 	if (rc != EOK) {
 		printf("Error creating window.\n");
@@ -464,4 +484,10 @@
 
 	return EOK;
+}
+
+static void wnd_kbd_event(void *arg, kbd_event_t *event)
+{
+	printf("Keyboard event type=%d key=%d\n", event->type, event->key);
+	quit = true;
 }
 
