{hero}

keys.enable()

Since: KeyTable 2.0.0

Enable or disable KeyTable's interactions (mouse and keyboard).
Please note - this property requires the KeyTable extension for DataTables.

Description

KeyTable is typically used as an enabler for other interaction options with a DataTable, such as editing a cell's content or triggering an action that will display additional information about a cell or row. In such circumstances it is important that we have the ability to control KeyTable's own listeners so which keystrokes it acts upon can be finely controls as required by your situation. This method provides that ability.

When fully enabled KeyTable, when a cell has focus, will listen for all non-special character key presses (i.e. shift, cmd / ctrl and alt are ignored) and trigger the key event. However, you may wish to stop KeyTable from listening for certain events, such as letters while editing a field. To provide this ability the method accepts an optional parameter that will inform KeyTable what level of listeners you would like it to listen for and act upon.

Please note that KeyTable's key listener is triggered on the keydown event and if KeyTable performs an action on the key (move focus for example) it will automatically call the stopPropagation() method of the event.

Type

function keys.enable( [ options ] )

Description:

Enable end user and API modification of the focused cells in the DataTable. Differing levels of enablement are available via the optional parameter.

Parameters:
Returns:

DataTables API instance

Example

Only allow navigation (i.e. letter keys perform no action and trigger no events):

var table = new DataTable('#myTable', {
	keys: true
});

table.keys.enable('navigation-only');

Related

The following options are directly related and may also be useful in your application development.