Disabling Keyboard Actions

Hi,

Listbox component is capturing keyboard events like 'a' or 'space'. I think the events are captured by "keyDownHandler". The keyboard shortcuts are interfering with my other custom events. Is there a way to disable them ?


2 Replies 1 reply marked as answer

JS Janakiraman Sakthivel Syncfusion Team March 22, 2022 03:26 AM UTC

Hi Halit, 

 
We need to validate more on this. So, we will update you the further details on March 24, 2022. We appreciate your patience until then. 

  
Regards, 
Janakiraman S. 



SP Sangeetha Priya Murugan Syncfusion Team March 29, 2022 01:34 PM UTC

Hi Halit,


Your requirement can be achivebale in our LIstbox by binding the keyDown event in Listbox created event as like as below.


 

function onCreated(): void {

  document

    .getElementsByClassName('e-listbox-wrapper e-custom')[0]

    .querySelectorAll('.e-list-parent')[0]

    .addEventListener(

      'keydown',

      function (e) {

        if (e.keyCode == 65 || e.keyCode == 97) {

          // prevent ctrl+ a action

          e.stopImmediatePropagation();

          // do your own action here

        }

      },

      true

    );

}

 

// Initialize ListBox component.

let listObj: ListBox = new ListBox({

  // Set the data source property.

  dataSource: (data as any).info,

  created: onCreated,

  cssClass: 'e-custom',

});

 


For your convenience, we have prepared the sample based on our suggestion.  In this we have prevented the Ctrl + A action in created event with custom CSS and do your own customization in that event based on your need. Please find the link below.


Sample Link: https://stackblitz.com/edit/r6f9ya?file=index.ts


Could you please check the attached sample and get back to us, if you need any further assistance on this.


Regards,

Sangeetha M


Marked as answer
Loader.
Up arrow icon