mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
375 B
23 lines
375 B
6 years ago
|
<input on:enter='this.blur()'>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
events: {
|
||
|
enter(node, callback) {
|
||
|
function handleKeydown(event) {
|
||
|
if (event.which === 13) {
|
||
|
callback();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
node.addEventListener('keydown', handleKeydown);
|
||
|
|
||
|
return {
|
||
|
destroy() {
|
||
|
node.removeEventListener('keydown', handleKeydown);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
</script>
|