diff --git a/ChangeLog b/ChangeLog
index 3295fd04a30728ec1e6cda1f3ab674f0b1f0f7de..79910ba9af36fa6d239106be690e3edb5ea6f854 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -285,6 +285,9 @@ CVS code -
 	  (DLR)
 	- If we get Escape followed by an escape sequence, interpret the
 	  escape sequence for consistency. (DLR)
+  parse_escape_seq_kbinput()
+	- New function used to interpret escape sequences, formerly part
+	  of parse_kbinput(). (DLR)
   get_control_kbinput()
 	- Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno
 	  Schulenberg)
diff --git a/src/proto.h b/src/proto.h
index b55e8fa93f0f24adfe2b6ddd3dc27c3d7bfe2642..8cba71b2c3b4088a092d9e1e1f73d9dedb2702bb 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -726,6 +726,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
 int get_escape_seq_kbinput(const int *seq, size_t seq_len, bool
 	*ignore_seq);
 int get_escape_seq_abcd(int kbinput);
+int parse_escape_seq_kbinput(int kbinput);
 int get_byte_kbinput(int kbinput);
 long get_unicode_kbinput(int kbinput);
 int get_control_kbinput(int kbinput);
diff --git a/src/winio.c b/src/winio.c
index f31f823b8079a1cda6d15c76b2f4fe6786cf49b4..526a4166483c8dd28ec7db9274ed8b7a54a3e57a 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -520,29 +520,8 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
 		    if (get_key_buffer_len() == 0) {
 			*meta_key = TRUE;
 			retval = tolower(*kbinput);
-		    } else {
-			int *seq;
-			size_t seq_len;
-			bool ignore_seq;
-
-			/* Put back the non-escape character, get the
-			 * complete escape sequence, translate the
-			 * sequence into its corresponding key value,
-			 * and save that as the result. */
-			unget_input(kbinput, 1);
-			seq_len = get_key_buffer_len();
-			seq = get_input(NULL, seq_len);
-			retval = get_escape_seq_kbinput(seq, seq_len,
-				&ignore_seq);
-
-			/* If the escape sequence is unrecognized and
-			 * not ignored, throw it out, and indicate this
-			 * on the statusbar. */
-			if (retval == ERR && !ignore_seq)
-			    statusbar(_("Unknown Command"));
-
-			free(seq);
-		    }
+		    } else
+			retval = parse_escape_seq_kbinput(*kbinput);
 		    break;
 		case 2:
 		    /* Two escapes followed by one or more decimal
@@ -619,29 +598,8 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
 			    byte_digits = 0;
 			    retval = *kbinput;
 			}
-		    } else {
-			int *seq;
-			size_t seq_len;
-			bool ignore_seq;
-
-			/* Put back the non-escape character, get the
-			 * complete escape sequence, translate the
-			 * sequence into its corresponding key value,
-			 * and save that as the result. */
-			unget_input(kbinput, 1);
-			seq_len = get_key_buffer_len();
-			seq = get_input(NULL, seq_len);
-			retval = get_escape_seq_kbinput(seq, seq_len,
-				&ignore_seq);
-
-			/* If the escape sequence is unrecognized and
-			 * not ignored, throw it out, and indicate this
-			 * on the statusbar. */
-			if (retval == ERR && !ignore_seq)
-			    statusbar(_("Unknown Command"));
-
-			free(seq);
-		    }
+		    } else
+			retval = parse_escape_seq_kbinput(*kbinput);
 		    break;
 	    }
     }
@@ -1194,6 +1152,37 @@ int get_escape_seq_abcd(int kbinput)
     }
 }
 
+/* Interpret the escape sequence in the keystroke buffer, the first
+ * character of which is kbinput.  Assume that the keystroke buffer
+ * isn't empty, and that the initial escape has already been read in. */
+int parse_escape_seq_kbinput(int kbinput)
+{
+    int retval, *seq;
+    size_t seq_len;
+    bool ignore_seq;
+
+    /* Put back the non-escape character, get the complete escape
+     * sequence, translate the sequence into its corresponding key
+     * value, and save that as the result. */
+    unget_input(&kbinput, 1);
+    seq_len = get_key_buffer_len();
+    seq = get_input(NULL, seq_len);
+    retval = get_escape_seq_kbinput(seq, seq_len, &ignore_seq);
+
+    /* If the escape sequence is unrecognized and not ignored, throw it
+     * out, and indicate this on the statusbar. */
+    if (retval == ERR && !ignore_seq)
+	statusbar(_("Unknown Command"));
+
+    free(seq);
+
+#ifdef DEBUG
+    fprintf(stderr, "parse_escape_seq_kbinput(): kbinput = %d, seq_len = %lu, ignore_seq = %d, retval = %d\n", *kbinput, (unsigned long)seq_len, (int)ignore_seq, retval);
+#endif
+
+    return retval;
+}
+
 /* Translate a byte sequence: turn a three-digit decimal number from
  * 000 to 255 into its corresponding byte value. */
 int get_byte_kbinput(int kbinput)