[] 
(Showing Draft Content)

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.


The following code sample specifies the keys for moving left.

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

The following code sample changes the action of the default up and down arrow keys for the active cell.

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);

The following code sample creates a custom action map for Enter key.

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);

The following code sample deactivates default key actions by removing default up and down arrow key actions.

 $(document).ready(function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount:3}); var activeSheet = spread.getActiveSheet(); var manager = spread.commandManager(); var upKey = manager.setShortcutKey(undefined, GC.Spread.Commands.Key.up, false, false, false, false); var downKey = manager.setShortcutKey(undefined, GC.Spread.Commands.Key.down, false, false, false, false); });