I have a sp-textfield
and I’d like to capture the value when user presses Enter
key.
Now normally in Vanilla JS I’d listen for keypress
event and match the key
, like following for example:
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();
// do stuff
}
});
But how can I do that in here? thanks!