Topic: Login Modal - best way to have the Enter Key click the Login Button?

cdenby pro asked 4 years ago

I'd like to have the enter key click the login button on a login modal. What's the cleanest way to do this?

cdenby pro commented 4 years ago

If the username or password has focus, the enter key should click the login button.

Mikołaj Smoleński staff answered 4 years ago

Hi, I suggest to use the following code:
$('input').on('keypress', (event)=> {
        if(event.which === 13){
Best Regards

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No