Commit 32dbcfd

mo khan <mo.khan@gmail.com>
2021-01-14 04:27:50
map CTRL+q to quit
1 parent 1f0e845
Changed files (1)
kilo.c
@@ -7,6 +7,10 @@
 #include <termios.h>
 #include <unistd.h>
 
+/*** defines ***/
+
+#define CTRL_KEY(k) ((k) & 0x1f)
+
 /*** data ***/
 
 struct termios orig_termios;
@@ -51,7 +55,7 @@ int main() {
     } else {
       printf("%d ('%c')\r\n", c, c);
     }
-    if (c == 'q') break;
+    if (c == CTRL_KEY('q')) break;
   }
 
   return 0;