Spread for ASP.NET 12 Product Documentation
AddKeyMap
Spread for ASP.NET 12 Product Documentation > Client-Side Scripting Reference > Scripting Members > Methods > AddKeyMap

This method allows you to map a keyboard key which will cause an action.

Syntax

[JavaScript]

FpSpread1.AddKeyMap(keycode,ctrl,shift,alt,action);

Parameters

keycode
Integer, key being pressed
ctrl
Boolean, Control key
shift
Boolean, Shift key
alt
Boolean, Alt key
action
Constant, CopyLikeExcel, PasteLikeExcel, MoveToPrevCell, MoveToNextCell, MoveToNextRow, MoveToPrevRow, MoveToFirstColumn, MoveToLastColumn, ScrollTo

Return Type

None

Remarks

This method allows you to set a JavaScript code action based on a key the user presses. The action can move to the next or previous cell or row, first or last column, or scroll to a cell.

Example

This is a sample that contains the method. On the client side, the script that contains the method would look like this:

JavaScript
Copy Code
<script type="text/javascript">
   function setMap() {
       var ss = document.getElementById("FpSpread1");
       if (ss != null){
          //IE9 or earlier
         //ss.AddKeyMap(13,true,true,false,"this.MoveToLastColumn()");
        ss.AddKeyMap(13,true,true,false,"element.MoveToLastColumn()");
   }
</script>

The following code passes a function to the AddKeyMap method. This code works for Microsoft Internet Explorer (IE) and Mozilla Firefox.

JavaScript
Copy Code
window.onload = function() {
           var spread1 = document.getElementById("FpSpread1");
           spread1.AddKeyMap(13, false, false, false, function() { var ss = spread1; ss.MoveToLastColumn(); });
       }
See Also