--- tinywm.c
+++ tinywm.c
@@ -4,6 +4,7 @@
  * and is provided AS IS, with NO WARRANTY. */
 
 #include <X11/Xlib.h>
+#include <stdlib.h>
 
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
@@ -18,6 +19,14 @@
 
     XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask,
             DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
+    XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F2")), Mod1Mask,
+	    			XDefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
+	  XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F4")), Mod1Mask,
+	    			XDefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);		
+    XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F12")), Mod1Mask,
+	    			XDefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);		
+  
+
     XGrabButton(dpy, 1, Mod1Mask, DefaultRootWindow(dpy), True,
             ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);
     XGrabButton(dpy, 3, Mod1Mask, DefaultRootWindow(dpy), True,
@@ -27,8 +36,30 @@
     for(;;)
     {
         XNextEvent(dpy, &ev);
+        if(ev.type == KeyPress){  
+          if(ev.xbutton.button == XKeysymToKeycode(dpy,XStringToKeysym("F2"))){
+            system("xterm &");
+          }
+          else if(ev.xbutton.button == XKeysymToKeycode(dpy,XStringToKeysym("F12"))){
+            exit(0);
+          }
+        }
         if(ev.type == KeyPress && ev.xkey.subwindow != None)
-            XRaiseWindow(dpy, ev.xkey.subwindow);
+        {
+            if(ev.xbutton.button == XKeysymToKeycode(dpy,XStringToKeysym("F4")) && ev.xkey.subwindow != None){
+						  XEvent event;
+  						event.xclient.type = ClientMessage;
+						  event.xclient.window = ev.xkey.subwindow;
+						  event.xclient.message_type = XInternAtom(dpy, "WM_PROTOCOLS", True);
+						  event.xclient.format = 32;
+						  event.xclient.data.l[0] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
+						  event.xclient.data.l[1] = CurrentTime;
+						  XSendEvent(dpy, ev.xkey.subwindow, False, NoEventMask, &event);
+            }else if(ev.xbutton.button == XKeysymToKeycode(dpy,XStringToKeysym("F1"))){
+              XRaiseWindow(dpy, ev.xkey.subwindow);
+              XSetInputFocus(dpy, ev.xkey.subwindow, RevertToParent, CurrentTime);
+            }
+        }
         else if(ev.type == ButtonPress && ev.xbutton.subwindow != None)
         {
             XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
