Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>ally.when.key Example</title>
</head>
<body>
<article id="example-introduction">
  <h1><code>ally.when.key</code> Example</h1>
  <p>Observe the browser&apos;s / JSBin&apos;s console when pressing <kbd>Enter</kbd> repeatedly, then <kbd>Escape</kbd> once. Note how the <kbd>Space</kbd> key is unaffected by the <kbd>Escape</kbd> key&apos;s disengagement.</p>
</article>
<div id="example-html">
</div>
<script src="https://cdn.jsdelivr.net/ally.js/1.4.1/ally.min.js"></script>
</body>
</html>
 
ally.when.key({
  enter: function(event) {
    event.preventDefault();
    console.log('pressed enter key');
  },
  escape: function(event, disengage) {
    event.preventDefault();
    console.log('pressed escape key');
    // stop enter and escape handling
    disengage();
  }
});
ally.when.key({
  space: function(event) {
    event.preventDefault();
    console.log('pressed space key');
  },
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
rodneyrehmpro
0viewers