Hopefully fix some input problems. If input does not work for you please let me know.
Modified: trunk/reactos/ntoskrnl/dbg/kdb.h
Modified: trunk/reactos/ntoskrnl/dbg/kdb_cli.c
Modified: trunk/reactos/ntoskrnl/dbg/kdb_keyboard.c
Modified: trunk/reactos/ntoskrnl/dbg/kdb_serial.c

Modified: trunk/reactos/ntoskrnl/dbg/kdb.h
--- trunk/reactos/ntoskrnl/dbg/kdb.h	2005-03-06 00:50:48 UTC (rev 13844)
+++ trunk/reactos/ntoskrnl/dbg/kdb.h	2005-03-06 02:06:11 UTC (rev 13845)
@@ -272,10 +272,15 @@
 
 #define KdbpSafeReadMemory(dst, src, size)   MmSafeCopyFromUser(dst, src, size)
 #define KdbpSafeWriteMemory(dst, src, size)  MmSafeCopyToUser(dst, src, size)
+
+#define KdbpGetCharKeyboard(ScanCode) KdbpTryGetCharKeyboard(ScanCode, 0)
 CHAR
-KdbpTryGetCharKeyboard(PULONG ScanCode);
-ULONG
-KdbpTryGetCharSerial(VOID);
+KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry);
+
+#define KdbpGetCharSerial()  KdbpTryGetCharSerial(0)
+CHAR
+KdbpTryGetCharSerial(UINT Retry);
+
 VOID
 KdbEnter(VOID);
 VOID

Modified: trunk/reactos/ntoskrnl/dbg/kdb_cli.c
--- trunk/reactos/ntoskrnl/dbg/kdb_cli.c	2005-03-06 00:50:48 UTC (rev 13844)
+++ trunk/reactos/ntoskrnl/dbg/kdb_cli.c	2005-03-06 02:06:11 UTC (rev 13845)
@@ -1682,6 +1682,7 @@
    INT Length;
    INT i;
    INT RowsPrintedByTerminal;
+   ULONG ScanCode;
    va_list ap;
 
    /* Check if the user has aborted output of the current command */
@@ -1703,20 +1704,17 @@
       {
          /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
          TerminalReportsSize = FALSE;
-         DbgPrint("\x1b[18t");
-         i = 10;
-         while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
+         //DbgPrint("\x1b[18t");
+         c = KdbpTryGetCharSerial(10);
          if (c == KEY_ESC)
          {
-            i = 5;
-            while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
+            c = KdbpTryGetCharSerial(5);
             if (c == '[')
             {
                Length = 0;
                for (;;)
                {
-                  i = 5;
-                  while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
+                  c = KdbpTryGetCharSerial(5);
                   if (c == -1)
                      break;
                   Buffer[Length++] = c;
@@ -1781,13 +1779,19 @@
          if (KdbNumberOfColsPrinted > 0)
             DbgPrint("\n");
          DbgPrint("--- Press q to abort, any other key to continue ---");
-         while ((c = KdbpTryGetCharSerial()) == -1);
+         if (KdDebugState & KD_DEBUG_KDSERIAL)
+            c = KdbpGetCharSerial();
+         else
+            c = KdbpGetCharKeyboard(&ScanCode);
          if (c == '\r')
          {
-            /* Ignore \r and wait for \n or another \r - if \n is not received here
+            /* Try to read '\n' which might follow '\r' - if \n is not received here
              * it will be interpreted as "return" when the next command should be read.
              */
-            while ((c = KdbpTryGetCharSerial()) == -1);
+            if (KdDebugState & KD_DEBUG_KDSERIAL)
+               c = KdbpTryGetCharSerial(5);
+            else
+               c = KdbpTryGetCharKeyboard(&ScanCode, 5);
          }
          DbgPrint("\n");
          if (c == 'q')
@@ -1914,7 +1918,7 @@
    OUT PCHAR Buffer,
    IN  ULONG Size)
 {
-   CHAR Key;
+   CHAR Key, NextKey;
    PCHAR Orig = Buffer;
    ULONG ScanCode = 0;
    BOOLEAN EchoOn;
@@ -1929,14 +1933,14 @@
    {
       if (KdDebugState & KD_DEBUG_KDSERIAL)
       {
-         while ((Key = KdbpTryGetCharSerial()) == -1);
+         Key = KdbpGetCharSerial();
          ScanCode = 0;
          if (Key == KEY_ESC) /* ESC */
          {
-            while ((Key = KdbpTryGetCharSerial()) == -1);
+            Key = KdbpGetCharSerial();
             if (Key == '[')
             {
-               while ((Key = KdbpTryGetCharSerial()) == -1);
+               Key = KdbpGetCharSerial();
                switch (Key)
                {
                case 'A':
@@ -1954,7 +1958,9 @@
          }
       }
       else
-         while ((Key = KdbpTryGetCharKeyboard(&ScanCode)) == -1);
+      {
+         Key = KdbpGetCharKeyboard(&ScanCode);
+      }
 
       if ((Buffer - Orig) >= (Size - 1))
       {
@@ -1965,10 +1971,13 @@
 
       if (Key == '\r')
       {
-         /* Ignore this key... */
-      }
-      else if (Key == '\n')
-      {
+         /* Read the next char - this is to throw away a \n which most clients should
+          * send after \r.
+          */
+         if (KdDebugState & KD_DEBUG_KDSERIAL)
+            NextKey = KdbpTryGetCharSerial(5);
+         else
+            NextKey = KdbpTryGetCharKeyboard(&ScanCode, 5);
          DbgPrint("\n");
 	 /*
 	  * Repeat the last command if the user presses enter. Reduces the

Modified: trunk/reactos/ntoskrnl/dbg/kdb_keyboard.c
--- trunk/reactos/ntoskrnl/dbg/kdb_keyboard.c	2005-03-06 00:50:48 UTC (rev 13844)
+++ trunk/reactos/ntoskrnl/dbg/kdb_keyboard.c	2005-03-06 02:06:11 UTC (rev 13845)
@@ -62,12 +62,13 @@
 }
 
 CHAR
-KdbpTryGetCharKeyboard(PULONG ScanCode)
+KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry)
 {
     static byte_t last_key = 0;
     static byte_t shift = 0;
     char c;
-    while(1) {
+    BOOLEAN KeepRetrying = (Retry == 0);
+    while (KeepRetrying || Retry-- > 0) {
 	unsigned char status = kbd_read_status();
 	while (status & KBD_STAT_OBF) {
 	    byte_t scancode;
@@ -91,6 +92,8 @@
 	    }
 	}
     }
+    
+    return -1;
 }
 
 #endif

Modified: trunk/reactos/ntoskrnl/dbg/kdb_serial.c
--- trunk/reactos/ntoskrnl/dbg/kdb_serial.c	2005-03-06 00:50:48 UTC (rev 13844)
+++ trunk/reactos/ntoskrnl/dbg/kdb_serial.c	2005-03-06 02:06:11 UTC (rev 13845)
@@ -20,11 +20,14 @@
 
 
 CHAR
-KdbpTryGetCharSerial()
+KdbpTryGetCharSerial(UINT Retry)
 {
-  UCHAR Result;
+  CHAR Result = -1;
 
-  while( !KdPortGetByteEx (&LogPortInfo, &Result) );
+  if (Retry == 0)
+     while (!KdPortGetByteEx(&LogPortInfo, (PUCHAR)&Result));
+  else
+     while (!KdPortGetByteEx(&LogPortInfo, (PUCHAR)&Result) && Retry-- > 0);
 
   return Result;
 }