DevExtreme Vue - Keyboard Support

An end user can use the following keys to interact with the widget.

Key Action
↑ or mouse wheel up Increases the widget value by a step.
↓ or mouse wheel down Decreases the widget value by a step.

You can implement a custom handler for a key using the registerKeyHandler(key, handler) method.

  • <template>
  • <DxNumberBox :ref="myNumberBoxRef" />
  • </template>
  • <script>
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import DxNumberBox from 'devextreme-vue/number-box';
  •  
  • const myNumberBoxRef = 'my-number-box';
  •  
  • export default {
  • components: {
  • DxNumberBox
  • },
  • data() {
  • return {
  • myNumberBoxRef
  • }
  • },
  • computed: {
  • numberBox: function() {
  • return this.$refs[myNumberBoxRef].instance;
  • }
  • },
  • mounted: function() {
  • this.numberBox.registerKeyHandler('backspace', function(e) {
  • // The argument "e" contains information on the event
  • });
  • this.numberBox.registerKeyHandler('space', function(e) {
  • // ...
  • });
  • }
  • }
  • </script>
See Also