Enter bilan tugmani ishga tushirish
JavaScript yordamida klaviaturada "Enter" bosilganda tugma bosilishini ishga tushiring.
Enter bosilganda tugma bosilishini ishga tushirish
Tugmani ishga tushirish uchun kiritish maydoni ichida "Enter" tugmasini bosing:
Misol
// Get the input field
var input = document.getElementById("myInput");
// Execute a function when the user presses a key on the keyboard
input.addEventListener("keypress", function(event) {
// If the user presses the "Enter" key on the keyboard
if (event.key === "Enter") {
// Cancel the default action, if needed
event.preventDefault();
// Trigger the button element with a click
document.getElementById("myBtn").click();
}
});
O‘zingiz sinab ko‘ring »
Maslahat: JavaScript ma’lumotnomamizda KeyboardEvent key xossasi haqida ko‘proq bilib oling.
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
