Explorar o código

Add period and equal directives (#2000)

* Add period and equal directives

* Add documentation
Sam Snelling %!s(int64=3) %!d(string=hai) anos
pai
achega
481461bc93

+ 2 - 0
packages/alpinejs/src/utils/on.js

@@ -182,6 +182,8 @@ function keyToModifiers(key) {
         'down': 'arrow-down',
         'left': 'arrow-left',
         'right': 'arrow-right',
+        'period': '.',
+        'equal': '=',
     }
 
     modifierToKeyMap[key] = key

+ 2 - 0
packages/docs/src/en/directives/on.md

@@ -85,6 +85,8 @@ For easy reference, here is a list of common keys you may want to listen for.
 | `.escape`                   | Escape                      |
 | `.tab`                      | Tab                         |
 | `.caps-lock`                | Caps Lock                   |
+| `.equal`                    | Equal, `=`                  |
+| `.period`                   | Period, `.`                 |
 
 <a name="custom-events"></a>
 ## Custom events

+ 6 - 0
tests/cypress/integration/directives/x-on.spec.js

@@ -257,6 +257,8 @@ test('keydown modifiers',
                 x-on:keydown.esc="count++"
                 x-on:keydown.ctrl="count++"
                 x-on:keydown.slash="count++"
+                x-on:keydown.period="count++"
+                x-on:keydown.equal="count++"
             >
 
             <span x-text="count"></span>
@@ -286,6 +288,10 @@ test('keydown modifiers',
         get('span').should(haveText('21'))
         get('input').type('/')
         get('span').should(haveText('23'))
+        get('input').type('=')
+        get('span').should(haveText('25'))
+        get('input').type('.')
+        get('span').should(haveText('27'))
     }
 )