Enter key in forms and inputs

Enter key in forms and inputs


Hi all,

I noticed that the platform (9.0) automaticaly adds in every input:

onkeydown="return OsEnterKey('SOMETHING', arguments[0] || window.event)"

I was wondering if there's a way to tell the platform NOT to do this or at least override this. Does somebody know how or if it's possible?
I don't want the onkeydown event beeing catched in every input.


Hi again,

I'm going to answer myself.
I've placed this tiny piece of JQuery in the espace Javascript:

osjs(document).ready(function() { $(":input[onkeydown]").attr('onkeydown', ''); $(window).keydown(function(event) { if(event.keyCode == 13) { if($(document.activeElement).prop("tagName").toLowerCase() == 'textarea') return true; return false; } }); });

It deletes the onkeydown in every input that has it.
Then it monitors the keypressed in the window. If it's an ENTER and the user is not in a text area, it cancels it.

If anyone has a more elegant solution, please share it.

Hello Gonçalo,

Thank you for posting your question and solution. I haven't figured out a more elegenat solution yet but if I do I will update my post.

Kind regards