diff --git a/js/civicrm_stripe.js b/js/civicrm_stripe.js
index c695e9204b2b5f8faa2f591dd6977e525919d603..2a54a785cccd69c2c6b8cc74b7b4950f782fd268 100644
--- a/js/civicrm_stripe.js
+++ b/js/civicrm_stripe.js
@@ -321,8 +321,8 @@ CRM.$(function($) {
         addDrupalWebformActionElement(this.value);
       });
       // If enter pressed, use our submit function
-      form.addEventListener('keydown', function (e) {
-        if (e.keyCode === 13) {
+      form.addEventListener('keydown', function (event) {
+        if (event.code === 'Enter') {
           addDrupalWebformActionElement(this.value);
           submit(event);
         }
@@ -588,9 +588,9 @@ CRM.$(function($) {
   function addSupportForCiviDiscount() {
     // Add a keypress handler to set flag if enter is pressed
     cividiscountElements = form.querySelectorAll('input#discountcode');
-    var cividiscountHandleKeydown = function(e) {
-        if (e.keyCode === 13) {
-          e.preventDefault();
+    var cividiscountHandleKeydown = function(event) {
+        if (event.code === 'Enter') {
+          event.preventDefault();
           debugging('adding submitdontprocess');
           form.dataset.submitdontprocess = true;
         }