Index: client/Client/Client.vcxproj
===================================================================
--- client/Client/Client.vcxproj	(revision 581058cb71bba1dc957b5c1cb18f354d29b38813)
+++ client/Client/Client.vcxproj	(revision cdb4bec03046cb6823e52433c95f41a2426aaa2f)
@@ -73,4 +73,5 @@
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\..\common\Common.h" />
     <ClInclude Include="..\..\common\Compiler.h" />
     <ClInclude Include="..\..\common\Message.h" />
Index: client/Client/Client.vcxproj.filters
===================================================================
--- client/Client/Client.vcxproj.filters	(revision 581058cb71bba1dc957b5c1cb18f354d29b38813)
+++ client/Client/Client.vcxproj.filters	(revision cdb4bec03046cb6823e52433c95f41a2426aaa2f)
@@ -72,4 +72,7 @@
       <Filter>Header Files\common</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\common\Common.h">
+      <Filter>Header Files\common</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
Index: client/Client/Textbox.cpp
===================================================================
--- client/Client/Textbox.cpp	(revision 581058cb71bba1dc957b5c1cb18f354d29b38813)
+++ client/Client/Textbox.cpp	(revision cdb4bec03046cb6823e52433c95f41a2426aaa2f)
@@ -10,4 +10,33 @@
    str = "";
    selected = false;
+   shiftPressed = false;
+   
+   // populate the shift map
+   for(int i=0; i<26; i++)
+      shiftMap['a'+i] = 'A'+i;
+
+   shiftMap['1'] = '!';
+   shiftMap['2'] = '@';
+   shiftMap['3'] = '#';
+   shiftMap['4'] = '$';
+   shiftMap['5'] = '%';
+   shiftMap['6'] = '^';
+   shiftMap['7'] = '&';
+   shiftMap['8'] = '*';
+   shiftMap['9'] = '(';
+   shiftMap['0'] = ')';
+
+   shiftMap['`'] = '~';
+   shiftMap['-'] = '_';
+   shiftMap['='] = '+';
+   shiftMap['['] = '{';
+   shiftMap[']'] = '}';
+   shiftMap['\\'] = '|';
+   shiftMap[';'] = ':';
+   shiftMap['\''] = '\"';
+   shiftMap[','] = '<';
+   shiftMap['.'] = '>';
+   shiftMap['/'] = '?';
+   shiftMap[' '] = ' ';
 }
 
@@ -70,17 +99,81 @@
       char newChar = 0;
 
-      if (ALLEGRO_KEY_A <= e.keyboard.keycode && e.keyboard.keycode <= ALLEGRO_KEY_Z) {
+      if (ALLEGRO_KEY_A <= e.keyboard.keycode && e.keyboard.keycode <= ALLEGRO_KEY_Z)
          newChar = 'a'+e.keyboard.keycode-ALLEGRO_KEY_A;
-         if (al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT))
-            newChar -= 32;
-      }
       else if (ALLEGRO_KEY_0 <= e.keyboard.keycode && e.keyboard.keycode <= ALLEGRO_KEY_9)
          newChar = '0'+e.keyboard.keycode-ALLEGRO_KEY_0;
-      else if (e.keyboard.keycode = ALLEGRO_KEY_BACKSPACE && str.size() > 0)
-         str = str.substr(0, str.size()-1);
+      else {
+         switch(e.keyboard.keycode)
+         {
+         case ALLEGRO_KEY_TILDE:
+            newChar = '`';
+            break;
+         case ALLEGRO_KEY_MINUS:
+            newChar = '-';
+            break;
+         case ALLEGRO_KEY_EQUALS:
+            newChar = '=';
+            break;
+         case ALLEGRO_KEY_OPENBRACE:
+            newChar = '[';
+            break;
+         case ALLEGRO_KEY_CLOSEBRACE:
+            newChar = ']';
+            break;
+         case ALLEGRO_KEY_SEMICOLON:
+            newChar = ';';
+            break;
+         case ALLEGRO_KEY_QUOTE:
+            newChar = '\'';
+            break;
+         case ALLEGRO_KEY_BACKSLASH:
+            newChar = '\\';
+            break;
+         case ALLEGRO_KEY_COMMA:
+            newChar = ',';
+            break;
+         case ALLEGRO_KEY_FULLSTOP:
+            newChar = '.';
+            break;
+         case ALLEGRO_KEY_SLASH:
+            newChar = '/';
+            break;
+         case ALLEGRO_KEY_SPACE:
+            newChar = ' ';
+            break;
+         case  ALLEGRO_KEY_BACKSPACE:
+            if (str.size() > 0)
+            {
+               str = str.substr(0, str.size()-1);
+               return true;
+            }
+            else
+               return false;
+            break;
+         case  ALLEGRO_KEY_LSHIFT:
+         case  ALLEGRO_KEY_RSHIFT:
+            shiftPressed = true;
+            break;
+         default:
+            cout << "unknown keycode: " << e.keyboard.keycode << endl;
+            break;
+         }
+      }
 
       if (newChar != 0) {
+         if (al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT))
+            newChar = shiftMap[newChar];
+
          str.append(1, newChar);
          return true;
+      }
+   }
+   else if (e.type == ALLEGRO_EVENT_KEY_UP) {
+      switch(e.keyboard.keycode)
+      {
+      case ALLEGRO_KEY_LSHIFT:
+      case ALLEGRO_KEY_RSHIFT:
+         shiftPressed = false;
+         break;
       }
    }
Index: client/Client/Textbox.h
===================================================================
--- client/Client/Textbox.h	(revision 581058cb71bba1dc957b5c1cb18f354d29b38813)
+++ client/Client/Textbox.h	(revision cdb4bec03046cb6823e52433c95f41a2426aaa2f)
@@ -5,4 +5,5 @@
 
 #include <string>
+#include <map>
 
 using namespace std;
@@ -14,4 +15,6 @@
    string str;
    bool selected;
+   bool shiftPressed;
+   map<char, char> shiftMap;
 
 public:
Index: client/Client/main.cpp
===================================================================
--- client/Client/main.cpp	(revision 581058cb71bba1dc957b5c1cb18f354d29b38813)
+++ client/Client/main.cpp	(revision cdb4bec03046cb6823e52433c95f41a2426aaa2f)
@@ -23,4 +23,5 @@
 #include "../../common/Compiler.h"
 #include "../../common/Message.h"
+#include "../../common/Common.h"
 
 #include "Window.h"
@@ -200,4 +201,6 @@
       error("socket");
 
+   set_nonblock(sock);
+
    server.sin_family = AF_INET;
    hp = gethostbyname(argv[1]);
@@ -209,5 +212,5 @@
 
    al_start_timer(timer);
- 
+
    while(!doexit)
    {
@@ -282,6 +285,13 @@
          }
       }
- 
-      if(redraw && al_is_event_queue_empty(event_queue)) {
+
+      if (receiveMessage(&msgFrom, sock, &from) >= 0)
+      {
+         processMessage(msgFrom, state, chatConsole);
+         cout << "state: " << state << endl;
+      }
+ 
+      if (redraw && al_is_event_queue_empty(event_queue))
+      {
          redraw = false;
  
@@ -364,4 +374,6 @@
       case STATE_START:
       {
+         cout << "In STATE_START" << endl;
+
          chatConsole.addLine(response);
 
@@ -448,7 +460,4 @@
 
    sendMessage(&msgTo, sock, &server);
-   receiveMessage(&msgFrom, sock, &from);
-   processMessage(msgFrom, state, chatConsole);
-   cout << "state: " << state << endl;
 }
 
@@ -468,7 +477,4 @@
 
    sendMessage(&msgTo, sock, &server);
-   receiveMessage(&msgFrom, sock, &from);
-   processMessage(msgFrom, state, chatConsole);
-   cout << "state: " << state << endl;
 }
 
@@ -482,6 +488,4 @@
 
    sendMessage(&msgTo, sock, &server);
-   receiveMessage(&msgFrom, sock, &from);
-   processMessage(msgFrom, state, chatConsole);
 }
 
@@ -502,5 +506,3 @@
 
    sendMessage(&msgTo, sock, &server);
-   receiveMessage(&msgFrom, sock, &from);
-   processMessage(msgFrom, state, chatConsole);
-}
+}
