Hello,
I'm trying to modify a search field to only trigger an API call OnKeyDown === 'Enter' instead of OnChange. It works with "return event.key === 'Enter'", but since that is deprecated I'm looking for the correct field to specify in js using the OutSystems API.Thanks!
Hi Ryan,
For the mentioned use case you can try the below JS:
var searchInpt = document.getElementById($parameters.SearchInputId); searchInpt.addEventListener('keypress', function (e) { var code = e.keyCode || e.which || e.charCode; if(code === 13) { //Enter keycode $actions.SearchFruitByFruitName(); } });
See this sample SearchInputDemo
Refer to the attached .oml file.
I hope this helps you!
Kind regards,
Benjith Sam
Thanks @Benjith Sam