Combination Keypress Example

by pushtell

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://rawgit.com/pushtell/keypress-combination/master/standalone.min.js"></script>
<!-- Bootstrap Boilerplate -->
<div class="container">
    <div class="row">
        <div class="col-xs-12">
          <br />
          <div class="well">
             Click <b>here</b> to shift focus to this frame then press CTRL-1 to trigger the callback.
          </div>
        </div>
    </div>
</div>

Babel + JSX

// Combination Keypress Example

// var KeypressCombinationEmitter = require("keypress-combination");

// KeypressCombinationEmitter is defined 
// in https://rawgit.com/pushtell/keypress-combination/master/standalone.min.js
// for JSFiddle testing purposes.

var emitter = new KeypressCombinationEmitter();

// CTRL Keycode: 17
// 1 Keycode: 49
var subscription = emitter.addListener(17, 49, function() {
  console.log("Pressed CTRL-1");
});