mishig HF staff commited on
Commit
007a2ef
1 Parent(s): 3f43fd8

Submit on enter

Browse files
Files changed (1) hide show
  1. src/routes/+page.svelte +14 -1
src/routes/+page.svelte CHANGED
@@ -251,6 +251,13 @@
251
  drawUploadedImg(file);
252
  }
253
 
 
 
 
 
 
 
 
254
  // original: https://gist.github.com/MonsieurV/fb640c29084c171b4444184858a91bc7
255
  function polyfillCreateImageBitmap() {
256
  window.createImageBitmap = async function (data: ImageData): Promise<ImageBitmap> {
@@ -320,7 +327,13 @@
320
  <div id="board-container" bind:this={canvasContainerEl} />
321
  <div>
322
  <div class="flex gap-x-2 mt-3 items-center justify-center {isLoading ? 'animate-pulse' : ''}">
323
- <input type="text" class="border-2 py-1" placeholder="Add prompt" bind:value={txt} />
 
 
 
 
 
 
324
  <button
325
  on:click={submitRequest}
326
  class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1.5 px-4"
 
251
  drawUploadedImg(file);
252
  }
253
 
254
+ function onKeyDown(e: KeyboardEvent) {
255
+ if (e.code === 'Enter') {
256
+ e.preventDefault();
257
+ submitRequest();
258
+ }
259
+ }
260
+
261
  // original: https://gist.github.com/MonsieurV/fb640c29084c171b4444184858a91bc7
262
  function polyfillCreateImageBitmap() {
263
  window.createImageBitmap = async function (data: ImageData): Promise<ImageBitmap> {
 
327
  <div id="board-container" bind:this={canvasContainerEl} />
328
  <div>
329
  <div class="flex gap-x-2 mt-3 items-center justify-center {isLoading ? 'animate-pulse' : ''}">
330
+ <input
331
+ type="text"
332
+ class="border-2 py-1"
333
+ placeholder="Add prompt"
334
+ on:keydown={onKeyDown}
335
+ bind:value={txt}
336
+ />
337
  <button
338
  on:click={submitRequest}
339
  class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1.5 px-4"