Key Bindings
Overview
The keybidings module allows you to bind different keyboard shortcuts to actions on your table, as long as it has focus .
This is enabled by default to allow you to navigate around cells when editing and scroll up and down your table using arrow keys and pageup/pagedown keys
Default Key Bindings
By default the following actions are bound to the listed key combinations:
Action | Default Key Combination (keycode) | Function |
---|---|---|
navPrev | ctrl + tab ("ctrl + 9") | Shift focus to the next editable cell on the left, if none available move to the right most editable cell on the row above |
navNext | tab ("9") | Shift focus to the next editable cell on the right, if none available move to left most editable cell on the row below |
navLeft | Shift focus to next editable cell on the left | |
navRight | Shift focus to next editable cell on the right | |
navUp | up arrow ("38") | Shift focus to the same cell in the row above |
navDown | down arrow ("40") | Shift focus to the same cell in the row below |
undo | ctrl + z ("ctrl + 90") | Undo last user data edit |
redo | ctrl + y ("ctrl + 89") | Redo last user data edit |
scrollPageUp | Page Up ("33") | scroll page up by table height |
scrollPageDown | Page Down ("34") | scroll page down by table height |
scrollToStart | Home ("36") | scroll to first row |
scrollToEnd | End ("35") | scroll to last row |
copyToClipboard | ctrl + c ("ctrl + 67") | copy table data to clipboard |
Customize Key Bindings
If you would prefer to use different key combinations then that is no problem, you can use the keybindings option to change any of the above bindings.
The keybindings option takes an object that should consist of properties with the name of the action you wish to bind and a value of the key code string.
The key code should consist of the keycodes for the keys to be pressed, separated by the + symbol. The exceptions to this are ctrl, shift and meta which should be used to check that the ctrl, shift or meta keys are pressed as well.
The example below shows how to change the key bindings for the redo function to user the ctrl and r keys:
var table = new Tabulator("#example-table", { keybindings:{ "redo" : "ctrl + 82", //bind redo function to ctrl + r }, });
Disable A Default Key Binding
To disable any of the default keybindings, pass a value of false to is property in the keybindings option:
var table = new Tabulator("#example-table", { keybindings:{ "navUp" : false, //disable navUp keybinding }, });
Disable All Key Bindings
To disable all key bindings set the keybindings option to false
var table = new Tabulator("#example-table", { keybindings:false, //disable all key bindings });