-
Notifications
You must be signed in to change notification settings - Fork 211
Open
Description
Description
The Slider widget defines keyBindings for keyboard navigation (arrow keys, HOME, END, etc.) but they are never functional because:
- The
onKeylistener is never registered (this.on('key', this.onKey)is not called) - No
userActionshandlers are defined for the action names in keyBindings
The source code even has a comment acknowledging this at line 93 of lib/document/Slider.js:
// Unused ATM: no onKey registered
Slider.prototype.keyBindings = {
UP: 'backward',
DOWN: 'forward',
LEFT: 'backward',
RIGHT: 'forward',
PAGE_UP: 'backward',
PAGE_DOWN: 'forward',
' ': 'forward',
HOME: 'start',
END: 'end'
};Expected Behavior
Arrow keys, HOME, END, PAGE_UP, PAGE_DOWN, and SPACE should navigate the slider when it has focus, similar to how BaseMenu and other widgets handle keyboard input.
Actual Behavior
Keyboard navigation does not work. Only mouse interactions (click, drag, wheel) function correctly.
Suggested Fix
- Add
userActionsto Slider.prototype with handlers for backward/forward/start/end:
Slider.prototype.userActions = {
backward: function() {
this.emit('slideStep', -1);
return true;
},
forward: function() {
this.emit('slideStep', 1);
return true;
},
start: function() {
this.setSlideRate(0);
return true;
},
end: function() {
this.setSlideRate(1);
return true;
}
};- Register the key listener in
initChildren()(after button creation):
this.on('key', this.onKey);This mirrors how BaseMenu registers its key listener at line 134 of BaseMenu.js.
Workaround
We are currently monkey-patching Slider.prototype to add the missing userActions and wrap initChildren to register the key listener.
Version
terminal-kit 3.1.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels