diff --git a/configure.ac b/configure.ac
index bed4b46ae301a6ee928739fa772804d6a7dffb3f..d8e9902b4bb253dea0841027d321de722a0c4ad8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -546,6 +546,9 @@ fi
 AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
 	     [AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.])],
 	     [], [$CURSES_LIB])
+AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
+	     [AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
+	     [], [$CURSES_LIB])
 AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
 	     [AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.])],
 	     [], [$CURSES_LIB])
diff --git a/src/nano.c b/src/nano.c
index e957874d3efa5d9bfcdc4d618cacf3377b139ef2..015909a1b274cb3312e511269670451843a9444d 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2513,7 +2513,7 @@ int main(int argc, char **argv)
     shiftaltdown = get_keycode("kDN4", SHIFT_ALT_DOWN);
 #endif
 
-#ifndef USE_SLANG
+#ifdef HAVE_SET_ESCDELAY
     /* Tell ncurses to pass the Esc key quickly. */
     set_escdelay(50);
 #endif