cancel
Showing results for 
Search instead for 
Did you mean: 

Deactivate 'ENTER' key when adding itrems to cart

Deactivate 'ENTER' key when adding itrems to cart

Is it possible to deactivate the 'Enter' key when adding items to cart? Only the 'ADD TO CART' button should add items to cart.

5 REPLIES

Re: Deactivate 'ENTER' key when adding itrems to cart

You have to add jquery to your product page,

jQuery(document).ready(function() {
  jQuery("#qty").keydown(function(event){
    if(event.keyCode == 13) {
      event.preventDefault();
      return false;
    }
  });
});
If Issue Solved, Click Kudos/Accept As solutions.

Re: Deactivate 'ENTER' key when adding itrems to cart

Thanks. Does this apply to Magento2.1 as my developer says Magnto 2.1 does not allow the deactivation of the enter key.

Thanks

Re: Deactivate 'ENTER' key when adding itrems to cart

That is Magento2.1 community version

Re: Deactivate 'ENTER' key when adding itrems to cart

Above code is working for all the Magento 2.* version. Its working fine for Magento 2.1 as well.

If Issue Solved, Click Kudos/Accept As solutions.

Re: Deactivate 'ENTER' key when adding itrems to cart

Now the developer says that this fix won't work because of customisation he has done. I doubt this is the case. The customisation done to the ordering process is to deactivate the add to cart button when an incorrect min order qty or multiples of qty is ordered for simple and grouped items