SpreadJS Documentation
addKeyMap Method
The unicode for the key.
true if the action uses the Ctrl key; otherwise, false.
true if the action uses the Shift key; otherwise, false.
true if the action uses the Alt key; otherwise, false.
true if the action uses the Command key on the Macintosh or the Windows key on Microsoft Windows; otherwise, false.
The action defined in GcSpread.Sheets.SpreadActions to add.
Adds the shortcut key for the specified action to the sheet.
Syntax
var instance = new GcSpread.Sheets.Sheet(name);
var value; // Type: any
value = instance.addKeyMap(keyCode, ctrl, shift, alt, meta, action);
function addKeyMap( 
   keyCode : number,
   ctrl : boolean,
   shift : boolean,
   alt : boolean,
   meta : boolean,
   action : Object
) : any;

Parameters

keyCode
The unicode for the key.
ctrl
true if the action uses the Ctrl key; otherwise, false.
shift
true if the action uses the Shift key; otherwise, false.
alt
true if the action uses the Alt key; otherwise, false.
meta
true if the action uses the Command key on the Macintosh or the Windows key on Microsoft Windows; otherwise, false.
action
The action defined in GcSpread.Sheets.SpreadActions to add.
Example
This example adds key maps to change the default actions of the up and down arrow keys.
var activeSheet = spread.getActiveSheet();
   //Change the default Up arrow key action to "Page Up" for the active cell.
    activeSheet.addKeyMap(GcSpread.Sheets.Key.up, false, false, false, false, GcSpread.Sheets.SpreadActions.navigationPageUp);
    //Change the default Down arrow key action to "Page Down" for the active cell.
    activeSheet.addKeyMap(GcSpread.Sheets.Key.down, false, false, false, false, GcSpread.Sheets.SpreadActions.navigationPageDown);
This example maps an action to the Enter key that changes the background color.
var activeSheet = spread.getActiveSheet();

//Map the created action to the Enter key.
activeSheet.addKeyMap(GcSpread.Sheets.Key.enter, false, false, false, false, ColorAction);

function ColorAction(){
//Click on a cell and press the Enter key.
activeSheet.getCell(activeSheet.getActiveRowIndex(), activeSheet.getActiveColumnIndex())
        .backColor("red");
}
This example creates a key map.
sheet.addKeyMap("M".charCodeAt(0),true,true,false, GcSpread.Sheets.SpreadActions.navigationLeft);
See Also

Reference

Sheet type

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.