Disable certain keyboard shortcuts of Angular Spreadsheet

Hey Syncfusion Team,

Syncfusion spreadsheet supports a list of keyboard shortcuts listed here:
https://help.syncfusion.com/angular/spreadsheet/keyboard-shortcuts

I want to disable some of them ( not all of them ​). Is there any integrated method in syncfusion for this?
Thank you.

Regards,

Vivek Singhal


5 Replies 1 reply marked as answer

SP Sangeetha Priya Murugan Syncfusion Team December 30, 2021 12:35 PM UTC

  
Hi Vivek, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your query and it can be achivable in our spreadsheet by binding the keyDown handler in created event as like in the below code example. 
 
Code Example: 
 
 
  created() { 
    this.spreadsheetObj.element.addEventListener( 
      'keydown', 
      (e) => { 
        if (e.keyCode === 86) { 
          // prevent ctrl+ v action 
          e.stopImmediatePropagation(); 
        } 
      }, 
      true 
    ); 
  } 
 
 
For your convenience we have prepared the sample based on our suggestion. In this we have prevented the Ctrl + V keyboard shortcut and you can skip the actions based on your need. Please find the sample link below. 
 
 
Could you please check the above sample and get back to us with more details like list of keyboard shortcuts that you need to skip. Based on that we will check and provide you a better solution quickly. 
 
Regards, 
Sangeetha M 



VS Vivek Singhal replied to Sangeetha Priya Murugan December 30, 2021 01:50 PM UTC

Hi Sangeetha,

Thanks for the response. I checked the demo and its working perfectly fine as intended.
Below are the shortcuts I want to ALLOW 

  1. Alt + Enter
  2. Backspace
  3. Ctrl + C
  4. Ctrl + S
  5. Ctrl + V
  6. Ctrl + X
  7. Delete
  8. Esc
  9. F2


Please try to implement below two as well if possible:

  1. Ctrl + Z ( For only value change action of cell, dont undo formatting action)
  2. Ctrl + Y ( For only value change action of cell, dont redo formatting action)

Thanks.

Best Regards,
Vivek Singhal


SP Sangeetha Priya Murugan Syncfusion Team December 31, 2021 01:02 PM UTC

Hi Vivek, 
 
Query #1: Shortcuts to allow 
 
Your requirement to allow particular keyboard shortcut actions in spreadsheet, can be achievable by using the keyDown handler in created event as like as below.  
 
Code Example: 
 
 
 created() { 
    this.spreadsheetObj.cellFormat({ fontWeight: 'bold' }, 'E31:F31'); 
    this.spreadsheetObj.cellFormat({ textAlign: 'right' }, 'E31'); 
    this.spreadsheetObj.numberFormat('$#,##0.00', 'F2:F31'); 
 
    this.spreadsheetObj.element.addEventListener( 
      'keydown', 
      (e) => { 
        if ( 
          e.ctrlKey && 
          (e.keyCode == 86 || 
            e.keyCode == 67 || 
            e.keyCode == 83 || 
            e.keyCode == 88 || 
            e.keyCode == 90 || 
            e.keyCode == 17 || 
            e.keyCode == 89) 
        ) { 
          return; //   keyboard shortcuts that need to work in your end 
        } else if ( 
          e.ctrlKey && 
          (e.keyCode === 66 || 
            e.keyCode === 73 || 
            e.keyCode === 85 || 
            e.keyCode === 53 || 
            e.keyCode === 70 || 
            e.keyCode === 71 || 
            e.keyCode === 75 || 
            e.keyCode === 79 || 
            e.keyCode === 72) 
        ) { 
          // prevent other Keyboard shortcut action 
          e.stopImmediatePropagation(); 
        } 
      }, 
      true 
    ); 
  } 
 
 
For your convenience we have prepared the sample based on our suggestion. In this we have skipped the condition for needed keyboard shortcuts actions in keyDown handler. Please find the below link. 
 
 
Query #2: Don’t undo/redo formatting actions. 
 
Currently we don’t have option to skip the particular action undo/redo in spreadsheet. 
 
Could you please check the above details and get back to us, if you need any further assistance on this. 
 
Regards, 
Sangeetha M 


Marked as answer

VS Vivek Singhal replied to Sangeetha Priya Murugan January 4, 2022 07:17 AM UTC

Hello Sangeetha,

Thanks for the help. It worked as per requirements.

Regards,

Vivek Singhal



SP Sangeetha Priya Murugan Syncfusion Team January 5, 2022 07:11 AM UTC

  
Hi Vivek, 
 
We are happy to hear that your requirement has been achieved. Kindly get back to us, if you need any further assistance. 
 
Regards, 
Sangeetha M 


Loader.
Up arrow icon