Index: uspace/drv/char/xtkbd/xtkbd.c
===================================================================
--- uspace/drv/char/xtkbd/xtkbd.c	(revision a84ddf0d5cc93090bf7aede743de7c8fb32c483a)
+++ uspace/drv/char/xtkbd/xtkbd.c	(revision bff90ba1040a500ae748d7d8df6a6511fd6383e6)
@@ -179,6 +179,5 @@
 /*----------------------------------------------------------------------------*/
 static int polling(void *);
-static void default_connection_handler(ddf_fun_t *fun,
-    ipc_callid_t icallid, ipc_call_t *icall);
+static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
 /*----------------------------------------------------------------------------*/
 /** Keyboard function ops. */
@@ -241,5 +240,5 @@
 {
 	assert(arg);
-	xt_kbd_t *kbd = arg;
+	const xt_kbd_t *kbd = arg;
 
 	assert(kbd->parent_sess);
@@ -255,22 +254,19 @@
 			map_size = sizeof(scanmap_e0) / sizeof(int);
 			size = char_dev_read(kbd->parent_sess, &code, 1);
-		}
-
-
-		kbd_event_type_t type;
-		if (code & 0x80) {
-			code &= ~0x80;
-			type = KEY_RELEASE;
-		} else {
-			type = KEY_PRESS;
-		}
-
-		if ((size_t) code >= map_size) {
-			ddf_msg(LVL_WARN,
-			    "Unknown scancode: %hhx, size: %zd", code, size);
+			// TODO handle print screen
+		}
+
+		/* Invalid read. */
+		if (size != 1) {
 			continue;
 		}
 
-		const unsigned key = map[code];
+
+		/* Bit 7 indicates press/release */
+		const kbd_event_type_t type =
+		    (code & 0x80) ? KEY_RELEASE : KEY_PRESS;
+		code &= ~0x80;
+
+		const unsigned key = (code < map_size) ? map[code] : 0;
 		if (key != 0) {
 			async_exch_t *exch =
@@ -283,4 +279,6 @@
 			async_msg_4(exch, KBDEV_EVENT, type, key, 0, 0);
 			async_exchange_end(exch);
+		} else {
+			ddf_msg(LVL_WARN, "Unknown scancode: %hhx", code);
 		}
 	}
