Skip to content

Instantly share code, notes, and snippets.

@ZoolWay
Last active May 30, 2017 07:36
Show Gist options
  • Save ZoolWay/5d7ca81605e8492b03ec859937c4149a to your computer and use it in GitHub Desktop.
Save ZoolWay/5d7ca81605e8492b03ec859937c4149a to your computer and use it in GitHub Desktop.
Aurelia KeyUp
<template>
<h1>Aurelia KeyUp/Down</h1>
<div>
<h2>KeyUp:</h2>
<div style="border:1px solid blue; padding: 1em; margin: 1em;" keyup.delegate="handleKeyUp($event)">
<input value.bind="myText & debounce:800" placeholder="type here" />
</div>
<div style="border:1px solid black; padding: 1em; margin: 1em;">
output: ${myText}
</div>
</div>
<div>
<h2>KeyDown:</h2>
<div style="border:1px solid blue; padding: 1em; margin: 1em;" keydown.delegate="handleKeyDown($event)">
<input value.bind="myText2 & debounce:800" placeholder="type here" />
</div>
<div style="border:1px solid black; padding: 1em; margin: 1em;">
output: ${myText2}
</div>
</div>
</template>
//import { observable } from 'aurelia-framework'
export class App {
myText = '';
myText2 = '';
handleKeyUp(ev) {
console.log('up', ev);
}
handleKeyDown(ev) {
console.log('down', ev);
return true;
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use.standardConfiguration();
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment