KendoReact Window disable keyboard navigation

1 Answer 495 Views
Window
Andrei
Top achievements
Rank 1
Iron
Iron
Iron
Andrei asked on 05 Jul 2021, 09:01 AM

Hello, im using KendoReact Window component and i need to disable keyboard movements with arrow keys, how do i do that?

here are the things i've tried:

1) set draggable={false} prop( window can't be dragged by mouse but arrow keys still work)

2) attach global on keydown event listener and use event.preventDefault(); ( window keeps keyboard movements and firing along side with the attached keydown listener functions )

1 Answer, 1 is accepted

Sort by
0
Ina
Telerik team
answered on 06 Jul 2021, 07:16 AM

Hello Andrei,

Thank you for your question.

The keyboard navigation of the KendoReact Window is always available, but I can suggest the following workaround for your use case:

https://stackblitz.com/edit/react-6btrza-wj8cct?file=app/main.jsx 

In this example, we are adding the event listener inside the `useEffect` hook. When we event is invoked the event handler is using the `stopPropagation` method in order to achieve the wanted behavior.

For more information about the `useEffect` hook, you can check the following article:

https://reactjs.org/docs/hooks-effect.html 

For more information about the `stopPropagation` method, you can check the following link:

https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation 

Please, let me know if you need more assistance.

Regards,
Ina
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Window
Asked by
Andrei
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Ina
Telerik team
Share this question
or