Row mulit-select on Mac using Command key
See original GitHub issueDescribe the bug
Users are conditioned to use the Command key when selecting multiple rows on Mac computers, but the code only matches against ctrlKey
.
Tabulator Info
- Which version of Tabulator are you using? v4.2.7
Expected behavior The Command key on Macs should work as Ctrl key in Windows to multiselect rows.
Additional context
I do not have a ton of experience with Mac computers, but in most cases, the Cmd key does in Mac OS, what the Ctrl key does in Windows. Users alerted me that the Command key does not work with selecting multiple rows in the grid. The code in modules/select_row.js
only checks for ctrlKey
on the keypress event object.
After researching and testing how to capture the Command key, I have found out that different browsers report different data for the event. The Cmd key on Mac is equivalent to the Win key on Windows, which reports 91 as the keycode (event.which
) in Chrome, Firefox, and Edge, and IE11. On Mac OS, the Cmd key reports keycode 91 under Safari and Chrome, but 224 under Firefox. The OSes and browsers report other vastly different values for event.key
and event.code
, so your best bet is to probably code off of event.which
to capture multiselect intent on Mac.
I don’t believe keycode 224 is mapped to anything else, so you could probably just write:
var ctrlKey = e.ctrlKey || e.which == 91 || e.which == 224;
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
I’m not a Mac user but I do have access to one, so I can give it a shot.
This has been merged in, and will be included in sundays 4.3 release.
Cheers
Oli 😃