Just as you can add event listeners to any DOM element, you can add event listeners to the window object with <svelte:window>.

On line 33, add the keydown listener:

<svelte:window on:keydown={handleKeydown}/>

As with DOM elements, you can add event modifiers like preventDefault.



			
loading editor...

Console

loading Svelte compiler...


			
loading editor...

Compiler options

result = svelte.compile(source, {
generate:
});


			
loading editor...