diff --git a/src/lib/components/contents/details/widgets/key-value/key-value-editor.svelte b/src/lib/components/contents/details/widgets/key-value/key-value-editor.svelte index 8da86468..01926c9b 100644 --- a/src/lib/components/contents/details/widgets/key-value/key-value-editor.svelte +++ b/src/lib/components/contents/details/widgets/key-value/key-value-editor.svelte @@ -169,32 +169,41 @@ {#each pairs as pair, index} - + { edited[index] = true; }} + onkeydown={(event) => { + // Move focus with Enter key + if (event.key === 'Enter' && !event.isComposing) { + /** @type {HTMLInputElement} */ ( + rowElements[index].querySelector('td.value input') + )?.focus(); + } + }} /> - + { - // Add new pair with Enter key - if ( - !event.isComposing && - event.key === 'Enter' && - index === pairs.length - 1 && - pairs.length < max - ) { - addPair(); + // Move focus or add a new pair with Enter key + if (event.key === 'Enter' && !event.isComposing) { + if (index < pairs.length - 1) { + rowElements[index + 1].querySelector('input')?.focus(); + } else if (pairs.length < max) { + addPair(); + } } }} />