I want to fire a javascript function called 'faster' whenever the period key is pressed. I first tried a method which had worked for other keys:
document.onkeydown = function(evt) { 
  evt.preventDefault();
  evt = evt || window.event;
  switch (evt.keyCode) {
     case 190:
         faster();
          break;
   }
};
I also tried this with the code 46, but still no luck. One post said that Mac keyboards are less reliable and suggested using onkeypress instead of onkeydown. I couldn't find a directly relevant example, but I tried this:
JavaScript
periodetect () {
    var c = e.which || e.keyCode;
    if (c=46) {
       faster();
    }
};
HTML
<BODY BGCOLOR="#CCCCCC" onkeypress="periodetect()">
Can anyone spot my beginner mistake or suggest alternative?