Added basic keypress events #1

Merged
merged 3 commits into from Sep 7, 2012

Conversation

Projects
None yet
2 participants
Contributor

doodlemoonch commented May 17, 2012

Added basic keypress events that uses initKeyboardEvent for browsers that support it and initKeyEvent for Gecko/Firefox.

Owner

tmcw commented May 17, 2012

Hey, a few things here - the various arguments to this function (keyCode, shiftkey, metakey, charCode) are hardcoded to null or 72, and probably should be customizable. The target is also hardcoded to null, so a dumb test like

<!DOCTYPE html>
<html>
  <head>
    <title>happen</title>
  </head>
  <body>
    <button id='b'>b</button>
    <script src='src/happen.js'>
    <script>
      window.onkeydown = function() {
        alert('hi');
      };
      document.getElementById('b').onclick = function() {
        happen.keydown();
      };
    </script>
  </body>
</html>

doesn't show any result. That and I'm not sure whether this level of abstraction for initKey event will work, though I haven't gotten tests running: object.property won't interpolate .property - perhaps you're looking for something like

initEvent = 'initKeyEvent';
evt[initEvent](...)

Otherwise looks great and would be a great addition to the library!

@tmcw tmcw merged commit 183c257 into tmcw:master Sep 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment