Key up, Key down identification

Posted by: rambabu on 6 March 2024, 8:07 am EST

  • Posted 6 March 2024, 8:07 am EST

    Hi,

    I am trying to identify if control key/ Shift key is pressed while making selection of the rows in selectionchanged handler as I want to handle some cases based on it.

    e.g:

    I have column1, column2 etc.

    While making a selection, I am selecting first row by clicking on column1 and then Shift+ key last row to select all.

    Then I am Ctrl+Key and clicking on Column2 for selecting random rows to make unselection, in this scenario, I want to handle few cases based on the binding but here the binding is still showing as column1 instead of column2. Hence want to know if Ctrl is clicked to make adjustments.

  • Posted 7 March 2024, 9:25 am EST

    Hi

    I would really appreciate your reply on this.

  • Posted 7 March 2024, 4:45 pm EST

    Hi Rambabu,

    The selectionChanged event does not provide access to the mouse or keyboard event, due to which the selection is changed in the FlexGrid, So you’ll need to handle the ‘mousedown’ event on the FlexGrid’s host element to get the information about control/shift key press on selection change. You can also use the ‘hitTest’ method of the flexgrid to get the exact information about the row/column clicked (in the case of MouseEvent).

    So, we suggest you to handle the ‘mousedown’ event to perform such tasks, instead of ‘selectionChanged’ event. In case, if still want to use the ‘selectionChanged’ event for this purpose, you can store the hitTest and other necessary information by handling the ‘mousedown’ event and then use this info, in the selectionChanged event. Please note that, you’ll need to put your code inside a setTimeout function in the ‘selectionChanged’ event in this case.

    Please refer to the following sample demonstrating the same - https://stackblitz.com/edit/angular-ivy-oybxcz?file=src%2Fapp%2Fapp.component.ts

    Regards

  • Posted 8 March 2024, 7:53 am EST

    Thank you. That helped.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels