Answers for "trigger a button when clicking on enter"

1

html javascript call function after pressing enter

var yourElement = document.getElementById("yourElement");
yourElement.addEventListener("keydown", function (e) {
    if (e.code === "Enter") {  //checks whether the pressed key is "Enter"
        validate(e);
    }
});

function validate(e) {
    var text = e.target.value;
    //validation of the input...
}
Posted by: Guest on April-23-2021
8

press button on enter

searchInput.onkeyup = function (e) {
    if (e.key === 'Enter') {
        searchBtn.click();
    }
}
Posted by: Guest on March-11-2021

Code answers related to "trigger a button when clicking on enter"

Code answers related to "Assembly"

Browse Popular Code Answers by Language