Spread.Sheets Documentation
Using Input Mapping
Spread.Sheets Documentation > Developer's Guide > Managing the User Interface > Using Input Mapping

You can change the keyboard keys that are used to trigger built-in actions to other keys. Actions include navigation, selection, cut, copy, paste, clear, undo, and redo.

Using Code

This example specifies the keys for moving left.

JavaScript
Copy Code
//use Control+Shift+b
spread.commandManager().setShortcutKey("navigationLeft","B".charCodeAt(0),true,true,false,false);

Using Code

This example changes the action of the default up and down arrow keys for the active cell.

JavaScript
Copy Code
var activeSheet = spread.getActiveSheet();
//Change the default Up arrow key action to "Page Up" for the active cell.
spread.commandManager().setShortcutKey("navigationPageUp", GC.Spread.Commands.Key.up, false, false, false, false);
//Change the default Down arrow key action to "Page Down" for the active cell.
spread.commandManager().setShortcutKey("navigationPageDown", GC.Spread.Commands.Key.down, false, false, false, false);

Using code

This example creates a custom action.

JavaScript
Copy Code

var activeSheet = spread.getActiveSheet();

spread.commandManager().register('myCmd',
       function ColorAction() {                    
            //Click on a cell and press the Enter key.
            activeSheet.getCell(activeSheet.getActiveRowIndex(), activeSheet.getActiveColumnIndex()).backColor("red");
                }
            );

       //Map the created action to the Enter key.
       spread.commandManager().setShortcutKey('myCmd', GC.Spread.Commands.Key.enter, false, false, false, false);

See Also