diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js b/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js index d33c82faa55..e94ce00340a 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js @@ -16,6 +16,33 @@ var metadataEditor = {}; +metadataEditor.metadataTree = { + + /** + * Key down event for all inputText elements in the metadata tree. + * If the key is "enter", handle it like a "tab"-event. + * @param event the corresponding key down event + * @param element the corresponding element + */ + handleKeyDown(event, element) { + // Check if the pressed key is 'Enter' + if (event.keyCode === 13 || event.key === "Enter") { + event.preventDefault(); + let form = element.form; + let focusableElements = Array.from(form.elements).filter((element) => { + return element.tabIndex >= 0; + }); + let index = focusableElements.indexOf(element); + let nextInput = focusableElements[index + 1]; + if (nextInput) { + // Focus on the next input element + nextInput.focus(); + } + } + }, + +}; + /** * Methods and events related to the gallery section of the meta data editor. */ diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataTreeTable.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataTreeTable.xhtml index 5de835f21f4..52c57607554 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataTreeTable.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataTreeTable.xhtml @@ -63,7 +63,8 @@ value="#{item.value}" disabled="#{not item.editable or readOnly}" required="#{item.required and (not empty param['editForm:save'] or not empty param['editForm:saveContinue'])}" - styleClass="#{not item.editable or readOnly ? 'read-only disabled' : ''}"> + styleClass="#{not item.editable or readOnly ? 'read-only disabled' : ''}" + onkeydown="metadataEditor.metadataTree.handleKeyDown(event, this)">