Skip to content

Commit e2c6615

Browse files
Add listener of Intro key for Modebar buttons
1 parent fd9ad69 commit e2c6615

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/components/modebar/modebar.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,18 @@ proto.update = function(graphInfo, buttons) {
4444

4545
this.element.setAttribute('id', modeBarId);
4646
this.element.setAttribute('role', 'toolbar');
47-
this.element.setAttribute('tabindex', '0')
47+
this.element.setAttribute('tabindex', '0');
48+
49+
this.element.addEventListener('keydown', function(e) {
50+
if (e.key === 'Enter' || e.key === ' ') {
51+
const activeButton = e.target.closest('.modebar-btn');
52+
if (activeButton) {
53+
activeButton.click();
54+
e.preventDefault();
55+
}
56+
}
57+
});
58+
4859
this._uid = modeBarId;
4960
this.element.className = 'modebar modebar--custom';
5061
if(context.displayModeBar === 'hover') this.element.className += ' modebar--hover ease-bg';

0 commit comments

Comments
 (0)