Keybindings are stored in mlbviewer as a dictionary of the action name and a list of keys that map to that action. For example, a sample keybinding may be stored as,
'RSS' : [ ord('w') ],
which means the RSS action (opening the RSS news feed) is mapped to the 'w' key (or more technically, the Unicode/ASCII integer represented by the 'w' key.
Default key bindings can be customized to use different keys by creating a $HOME/.mlb/keybindings file.
Here are the default keybindings:
DEFAULT_KEYBINDINGS = {
'RSS' : [ ord('w') ],
'UP' : [ curses.KEY_UP, ],
'DOWN' : [ curses.KEY_DOWN, ],
'LEFT' : [ curses.KEY_LEFT, ],
'RIGHT' : [ curses.KEY_RIGHT, ],
'VIDEO' : [ 10, ],
'AUDIO' : [ ord('a') ],
'HELP' : [ ord('h') ],
'JUMP' : [ ord('j') ],
'MEDIA_DEBUG' : [ ord('z') ],
'OPTIONS' : [ ord('o') ],
'LINE_SCORE' : [ ord('b') ],
'BOX_SCORE' : [ ord('x') ],
'MASTER_SCOREBOARD' : [ ord('m') ],
'CALENDAR' : [ ord('C') ],
'HIGHLIGHTS' : [ ord('t') ],
'HIGHLIGHTS_PLAYLIST': [ ord('y') ],
'STANDINGS' : [ ord('g') ],
'INNINGS' : [ ord('i') ],
'LISTINGS' : [ ord('l') ],
'REFRESH' : [ ord('r') ],
'NEXDEF' : [ ord('n') ],
'COVERAGE' : [ ord('s') ],
'SPEED' : [ ord('p') ],
'CONDENSED_GAME' : [ ord('c') ],
'RELOAD_CONFIG' : [ ord('R') ],
'QUIT' : [ ord('q') ],
'DEBUG' : [ ord('d') ],
'MILBTV' : [ ord('M') ],
}
To customize the keybindings, create the $HOME/.mlb/keybindings file that contains the action name and the key to map. Single key sequences are converted to their Unicode values unless that value is already in Unicode,
For example, the default binding for VIDEO action (play streaming video item) is 10 which is the Unicode value for "Enter".
To add a 'v' key binding for the VIDEO action, put the following in your $HOME/.mlb/keybindings file:
VIDEO=v
It is not necessary to map VIDEO to ord('v') as the keybindings library will take care of that detail.
To map the Esc key (a non-printable character that has a Unicode value) to listings:
LISTINGS=27
Some keybindings cannot be overridden as they are considered to be essential to the
mlbviewer syle and function. Even though the essential keybinding may not be overriden, additional bindings for the same action can be created.
Essential actions and their bindings that cannot be changed:
'UP'=curses.KEY_UP', 'DOWN=curses.KEY_DOWN', 'LEFT=curses.KEY_LEFT', 'RIGHT=curses.KEY_RIGHT', 'HELP=h', 'VIDEO=10', 'AUDIO=a'
However, as in the above example, 'VIDEO=v' can be added to the default binding.
Re-using existing keys without re-mapping the existing key may lead to unexpected results.
If $HOME/.mlb/keybindings has the following:
BOX_SCORE=b
without also remapping the LINE_SCORE action could result in the LINE_SCORE binding being retained while the BOX_SCORE action becomes unusable.