diff --git a/public/js/hint.js b/public/js/hint.js
index 96f08a3..1e5f6ec 100644
--- a/public/js/hint.js
+++ b/public/js/hint.js
@@ -1,10 +1,11 @@
 "use strict";
 
 /*
-Todo:
-- limit the view based on prefix matches
-- highlight matching substrings
-*/
+ * Todo:
+ * - limit the view based on prefix matches
+ * - highlight matching substrings
+ * - http://www.cryer.co.uk/resources/javascript/script20_respond_to_keypress.htm
+ */
 
 // Don't let events bubble up
 Event.prototype.halt = function () {
@@ -236,10 +237,10 @@
  */
 var PrefixAnalyzer = {
   _regex : new RegExp(
-    "(?:^|[^-a-zA-Z0-9])" +   // Anchor
-    "((?:[-a-zA-Z0-9]+?)\/" + // Foundry
+    "(?:^|[^-_a-zA-Z0-9])" +   // Anchor
+    "((?:[-_a-zA-Z0-9]+?)\/" + // Foundry
     "(?:" +
-    "(?:[-a-zA-Z0-9]+?)=" +   // Layer
+    "(?:[-_a-zA-Z0-9]+?)=" +   // Layer
     "(?:(?:[^:=\/ ]+?):)?" +  // Key
     ")?" +
     ")$"),
@@ -250,19 +251,36 @@
   }
 };
 
+function codeFromEvent (e) {
+  if ((e.charCode) && (e.keyCode==0))
+    return e.charCode
+  return e.keyCode;
+};
 
-/**
- * Event handling after a key pressed
+
+/*
+ * Event handling after a key is down
+ * for arrows!
  */
-function updateKey (that, e) {
+function updateKeyDown (that, e) {
+  var code = codeFromEvent(e);
   var menu = that.menu();
 
-  switch (e.key) {
-  case 'Esc':
+  /*
+   * keyCodes:
+   * - Down  = 40
+   * - Esc   = 27
+   * - Up    = 38
+   * - Enter = 13
+   * - shift = 16
+   * for characters use e.key
+   */
+  switch (code) {
+  case 27: // 'Esc'
     // Hide menu
     menu.hide();
     break;
-  case 'Down':
+  case 40: // 'Down'
     e.halt(); // No event propagation
 
     // Menu is not active
@@ -276,20 +294,20 @@
     };
 
     break;
-  case "Up":
+  case 38: // "Up"
     if (!menu.active)
       break;
     e.halt(); // No event propagation
     that.removePrefix();
     menu.prev();
     break;
-  case "Enter":
+  case 13: // "Enter"
     if (!menu.active)
       break;
     e.halt(); // No event propagation
     that.insertText(menu.getActiveItem().getAction());
     that.removePrefix();
-
+    
     // Remove menu
     menu.hide();
 
@@ -302,41 +320,43 @@
         e.target.getBoundingClientRect().right
       );
     };
-
+    
     break;
   default:
     if (!menu.active)
-      break;
+      return;
 
-    // key stroke is not a character
-    if (e.key.length != 1) {
-
-      // Key stroke is not a text modifying key
-      if (e.key != 'Shift' &&
-          e.key != 'Up'    &&
-          e.key != 'Down'  &&
-          e.key != 'Enter' &&
-	  e.key != 'Alt'   &&
-	  e.key != 'AltGraph' &&
-	  e.key != 'CapsLock') {
-	that.insertPrefix();
-	menu.hide();
-      };
-      break;
+    // Surpress propagation in firefox
+    if (e.key !== undefined && e.key.length != 1) {
+      menu.hide();
     };
-
-    e.halt(); // No event propagation
-    
-    // Try to identify prefix
-    if (menu.skipToPrefix(e.key))
-      break;
-
-    // Prefix not found
-    that.insertPrefix();
-    menu.hide();
   };
 };
 
+/**
+ * Event handling after a key pressed
+ * for characters!
+ */
+function updateKeyPress (that, e) {
+  var character = String.fromCharCode(codeFromEvent(e));
+  var menu = that.menu();
+
+  if (!menu.active)
+    return;
+
+  e.halt(); // No event propagation
+    
+  // Try to identify prefix
+  if (menu.skipToPrefix(character))
+    return;
+
+  // Prefix not found
+  that.insertPrefix();
+  menu.hide();
+};
+
+
+
 // new hint object
 var Hint = {
   _search   : undefined,   // Return the search element
@@ -369,9 +389,18 @@
 
     // Add event listener for key pressed down
     this._search.addEventListener(
+      "keypress",
+      function (e) {
+	updateKeyPress(that, e)
+      },
+      false
+    );
+
+    // Add event listener for key pressed down
+    this._search.addEventListener(
       "keydown",
       function (e) {
-	updateKey(that, e)
+	updateKeyDown(that, e)
       },
       false
     );
