--- keyboard.c_orig	2003-03-02 10:10:12.000000000 -0500
+++ keyboard.c	2003-03-02 11:10:28.000000000 -0500
@@ -196,6 +196,7 @@
 	unsigned char keycode;
 	char up_flag = down ? 0 : 0200;
 	char raw_mode;
+	char unexpected_up = 0;
 
 	pm_access(pm_kbd);
 	add_keyboard_randomness(scancode | up_flag);
@@ -212,18 +213,15 @@
 		tty = NULL;
 	}
 	kbd = kbd_table + fg_console;
-	if ((raw_mode = (kbd->kbdmode == VC_RAW))) {
-		put_queue(scancode | up_flag);
-		/* we do not return yet, because we want to maintain
-		   the key_down array, so that we have the correct
-		   values when finishing RAW mode or when changing VT's */
-	}
+	raw_mode = (kbd->kbdmode == VC_RAW);
 
 	/*
 	 *  Convert scancode to keycode
 	 */
-	if (!kbd_translate(scancode, &keycode, raw_mode))
+	if (!kbd_translate(scancode, &keycode, raw_mode)) {
+		if (raw_mode) put_queue(scancode | up_flag);
 		goto out;
+	}
 
 	/*
 	 * At this point the variable `keycode' contains the keycode.
@@ -234,11 +232,16 @@
 
 	if (up_flag) {
 		rep = 0;
-		if(!test_and_clear_bit(keycode, key_down))
+		if(!test_and_clear_bit(keycode, key_down)) {
 		    up_flag = kbd_unexpected_up(keycode);
+		    unexpected_up = 1;
+		}
 	} else
 		rep = test_and_set_bit(keycode, key_down);
 
+	if (raw_mode && (!unexpected_up || scancode == 0xFA))
+		put_queue(scancode | up_flag);
+
 #ifdef CONFIG_MAGIC_SYSRQ		/* Handle the SysRq Hack */
 	if (keycode == SYSRQ_KEY) {
 		sysrq_pressed = !up_flag;
