We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to customize the keyboard shortcuts in Spreadsheet

Platform: jQuery |
Control: ejSpreadSheet |
Published Date: August 31, 2018 |
Last Revised Date: May 22, 2019

Description

This knowledge base explains how to customize the keyboard shortcuts in Spreadsheet.

Solution

In the below code example, you can perform enter and delete keyboard shortcuts functionality when allowKeyboardNavigation property is set to false. It can be achieved by using “onEnterKeyDown()” and “onDeleteKeyDown()” extension method which is provided in the extension script (ejSpreadsheet-keyboard-extention.min.js).

 

HTML

 

<div id="Spreadsheet"></div>

 

JS

 

$("#Spreadsheet").ejSpreadsheet({
    allowKeyboardNavigation: false,
    loadComplete: "loadComplete",
    keyDown: "onKeyDown"
});
 
<script>
    function loadComplete(args) {
        //Here extend the ejSpreadsheet.Extension
        $.extend(this, ej.spreadsheetFeatures.extension);
    }
 
    function onKeyDown(args) {
        var ssObj = $("#Spreadsheet").data("ejSpreadsheet");
        if (args.event.key == "Enter")
            ssObj.onEnterKeyDown(args);
        else if (args.event.key == "Delete")
            ssObj.onDeleteKeyDown(args);
    }
</script>

 

Razor

 

@(Html.EJ().Spreadsheet<object>("Spreadsheet")
    .AllowKeyboardNavigation(false)
    .ClientSideEvents(
        events => events.LoadComplete("loadComplete").KeyDown("onKeyDown")
    )
)
 
<script>
    function loadComplete(args) {
        //Here extend the ejSpreadsheet.Extension
        $.extend(this, ej.spreadsheetFeatures.extension);
    }
 
    function onKeyDown(args) {
        var ssObj = $("#Spreadsheet").data("ejSpreadsheet");
        if (args.event.key == "Enter")
            ssObj.onEnterKeyDown(args);
        else if (args.event.key == "Delete")
            ssObj.onDeleteKeyDown(args);
    }
</script>

 

ASPX

 

<ej:Spreadsheet ID="Spreadsheet" AllowKeyboardNavigation="false" runat="server">
    <ClientSideEvents LoadComplete="loadComplete" KeyDown= "onKeyDown"/>
</ej:Spreadsheet>
 
<script>
    function loadComplete(args) {
        //Here extend the ejSpreadsheet.Extension
        $.extend(this, ej.spreadsheetFeatures.extension);
    }
 
    function onKeyDown(args) {
        var ssObj = $("#Spreadsheet").data("ejSpreadsheet");
        if (args.event.key == "Enter")
            ssObj.onEnterKeyDown(args);
        else if (args.event.key == "Delete")
            ssObj.onDeleteKeyDown(args);
    }
</script>

 

You can download the custom script ‘ejSpreadsheet-keyboard-extention.min.js’ from below link,

 

ejSpreadsheet-keyboard-extention

 

The list of available keyboard shortcuts in Spreadsheet can be found in the below documentation.

 

https://help.syncfusion.com/js/spreadsheet/keyboard-shortcuts

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile