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.
svelte/test/runtime/samples/event-handler-custom-this/main.html

23 lines
375 B

<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>