Delete button from keyboard is deleting files and folders

We are not providing the ability for user to delete but user is able to delete using keyboard delete key. How can I restrict the user to do that?


1 Reply

SM Shalini Maragathavel Syncfusion Team September 17, 2021 10:28 AM UTC

Hi Yamini, 

Greetings from  Syncfusion support. 

We checked your query and would like to let you know that, by default we do not have any direct property to prevent keyboard actions in File Manager component. However, you can achieve your requirement by binding the keyup and keydown event to File Manager component and prevent the keyboard interaction using keyboard prevention methods. Please refer to the below code snippet. 
  
export class AppComponent { 
  public ngOnInit(): void { 
    document.getElementById('filemanager').addEventListener('keyup', this.preventdelete, true); 
    document.getElementById('filemanager').addEventListener('keydown', this.preventdelete, true); 
  } 
 
  preventdelete(e) { 
    if (e.key == 'Delete') { 
      e.preventDefault(); 
      e.stopPropagation(); 
      e.stopImmediatePropagation(); 
    } 
  } 
} 

Ple
ase find the below sample for your reference, 
Please let us know if you need further assistance. 

Regards, 
Shalini M. 


Loader.
Up arrow icon