Skip to content

Commit

Permalink
Comma modifier to keyup and keydown events (#4170)
Browse files Browse the repository at this point in the history
* Added "comma" modifier to keydown and keyup events

* Tests for "comma" modifier for keyup and keydown events

* Documentation update for "comma" modifier for keyup and keydown events

---------

Co-authored-by: Mikko Ahonen <mikko@tanssi.io>
  • Loading branch information
mikko-ahonen and tanssinet authored Apr 24, 2024
1 parent 54c7eb7 commit e1893f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/alpinejs/src/utils/on.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function keyToModifiers(key) {
'left': 'arrow-left',
'right': 'arrow-right',
'period': '.',
'comma': ',',
'equal': '=',
'minus': '-',
'underscore': '_',
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/en/directives/on.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ For easy reference, here is a list of common keys you may want to listen for.
| `.caps-lock` | Caps Lock |
| `.equal` | Equal, `=` |
| `.period` | Period, `.` |
| `.comma` | Comma, `,` |
| `.slash` | Forward Slash, `/` |

<a name="custom-events"></a>
Expand Down
3 changes: 3 additions & 0 deletions tests/cypress/integration/directives/x-on.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ test('keydown modifiers',
x-on:keydown.slash="count++"
x-on:keydown.period="count++"
x-on:keydown.equal="count++"
x-on:keydown.comma="count++"
>
<span x-text="count"></span>
Expand Down Expand Up @@ -430,6 +431,8 @@ test('keydown modifiers',
get('span').should(haveText('25'))
get('input').type('.')
get('span').should(haveText('27'))
get('input').type(',')
get('span').should(haveText('29'))
}
)

Expand Down

0 comments on commit e1893f2

Please sign in to comment.