diff --git a/chatroom.js b/chatroom.js
index ba3a151..f8a89e9 100644
--- a/chatroom.js
+++ b/chatroom.js
@@ -39,6 +39,40 @@ Drupal.behaviors.chatroom = {
       Drupal.chatroom.initialised = true;
     }
 
+    // Autocomplete a username
+    $('#edit-chatroom-message-entry-box').keypress(function(e) {
+      var delimiters = new Array(" ", ",");
+      var key = new Array(e.keyCode ? e.keyCode : e.charCode, e.altKey, e.ctrlKey, e.shiftKey).toString();
+
+      // Key combinations that trigger autocomplete
+      var keys = new Array(
+        // (keycode, alt, ctrl, shift)
+        new Array(9, false, false, false).toString() // 'TAB'
+      );
+
+      if ($.inArray(key, keys) != -1) {
+        var input = $('#edit-chatroom-message-entry-box');
+        var end = input[0].selectionStart;
+        var value = input.val().substr(0, end);
+        var start = 0;
+        for (i = 0; i < delimiters.length; i++) {
+          index = value.lastIndexOf(delimiters[i]) + 1;
+          start = index > start ? index : start;
+        }
+        value = value.substr(start);
+        for (i = 0; i < Drupal.settings.chatroom.users.length; i++) {
+          name = Drupal.settings.chatroom.users[i];
+          if (value.toLowerCase() == name.substr(0, value.length).toLowerCase()) {
+            var replace = name;
+            break;
+          }
+        }
+        if (replace && start != end) {
+          input.val(input.val().substr(0, start) + replace + input.val().substr(end));
+        }
+        e.preventDefault();
+      }
+    });
     $('#edit-chatroom-message-entry-box').keyup(function(e) {
       var messageText = $('#edit-chatroom-message-entry-box').val().replace(/^\s+|\s+$/g, '');
       var anonNameText = '';
@@ -181,6 +215,7 @@ Drupal.chatroom.pollHandler = function(response, responseStatus) {
   }
 
   if (response.data.usersHtml) {
+    Drupal.settings.chatroom.users = response.data.users
     Drupal.chatroom.updateUserList(response.data.usersHtml);
   }
 
diff --git a/chatroom.module b/chatroom.module
index 8655d1b..0596c01 100644
--- a/chatroom.module
+++ b/chatroom.module
@@ -1020,6 +1020,7 @@ function chatroom_add_js($node) {
     'skipCacheCheckCount' => 5,
     'latestMsgId' => $node->chat->latest_msg ? $node->chat->latest_msg->cmid : 0,
     'accessDeniedPath' => 'chatroom/access-denied',
+    'users' => chatroom_build_users_array(chatroom_load_online_users($node)),
   );
 
   // Allow other modules to supply a polling backend.
@@ -1184,6 +1185,20 @@ function chatroom_load_online_users($chat) {
 }
 
 /**
+ * Builds an array of usernames to use for client-side auto-completion.
+ */
+function chatroom_build_users_array($chat_users) {
+  global $user;
+  $users = array();
+  foreach ($chat_users as $chat_user) {
+    if ($chat_user->uid != $user->uid || !user_is_logged_in()) {
+      $users[] = $chat_user->name;
+    }
+  }
+  return $users;
+}
+
+/**
  * updates chat's cache file modified time
  */
 function chatroom_chat_update_cache($chat_id, $latest_msg_id) {
@@ -1276,7 +1291,9 @@ function chatroom_chat_get_latest_messages($node, $last_msg_id, $command_respons
       chatroom_chat_update_cache($node->nid, $latest_msg_id);
     }
 
-    $response['usersHtml'] = theme('chatroom_user_list', chatroom_load_online_users($node), $node);
+    $chat_users = chatroom_load_online_users($node);
+    $response['users'] = chatroom_build_users_array($chat_users);
+    $response['usersHtml'] = theme('chatroom_user_list', array('users' => $chat_users, 'node' => $node));
     if (is_object($command_response)) {
       $response['commandResponse'] = $command_response;
     }
@@ -2041,9 +2058,11 @@ function chatroom_chat_ajax_user_add($node) {
   $user_data = array('uid' => $chat_user->uid, 'nid' => $node->nid);
   drupal_write_record('chatroom_chat_user', $user_data);
 
-  $new_user_list_html = theme('chatroom_user_list', chatroom_load_online_users($node), $node);
+  $chat_users = chatroom_load_online_users($node);
+  $users = chatroom_build_users_array($chat_users);
+  $new_user_list_html = theme('chatroom_user_list', array('users' => $chat_users, 'node' => $node));
   $user_added_message = theme('chatroom_system_message', t('User %username added', array('%username' => $chat_user->name)), $node);
-  drupal_json(array('data' => array('userAdded' => $user_added_message, 'usersHtml' => $new_user_list_html)));
+  drupal_json(array('data' => array('userAdded' => $user_added_message, 'usersHtml' => $new_user_list_html, 'users' => $users)));
 }
 
 /**
