Articles in this section
Category / Section

How to Disable Keyboard Interaction for Vue Diagram?

2 mins read

By default, the Syncfusion® Vue Diagram provides support for interacting with elements using key gestures, with several in-built commands bound to specific key combinations. You can refer to the following link to see the default key bindings for the diagram.

Keyboard Documentation: Keyboard Commands in Vue

Currently, there is no direct option to disable all keyboard interactions in the diagram component. However, you can achieve this by binding keyboard events using event listeners for Keydown and Keyup event and calling event.preventDefault() to prevent the default action, as well as event.stopPropagation() to stop the event from propagating up or down the DOM tree. This approach prevents keyboard events from reaching the diagram component and triggering any actions.

Refer to the following code snippet and sample for guidance:

<script>
export default {
 methods: {
   // Method to block keyboard events
   blockKeyboardEvent(event) {
     event.preventDefault();  // Block system keyboard actions
     event.stopPropagation(); // Prevent event from reaching diagram
   },
 },
 mounted() {
   const diagramElement = document.getElementById('diagram');

   // Add event listeners
   diagramElement.addEventListener('keydown', this.blockKeyboardEvent, true);
   diagramElement.addEventListener('keyup', this.blockKeyboardEvent, true);
 },
 beforeUnmount() {
   const diagramElement = document.getElementById('diagram');

   // Remove event listeners on component unmount
   diagramElement.removeEventListener('keydown', this.blockKeyboardEvent, true);
   diagramElement.removeEventListener('keyup', this.blockKeyboardEvent, true);
 }
};
</script>

Sample: Disabled Keyboard interactions Sample
[Note: This will also disable any keyboard inputs during annotation editing]

Conclusion
I hope you enjoyed learning how to disable Keyboard interaction for Vue Diagram.
You can refer to our Vue Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied