How does keyup.tab block browser default events in vue

binding keyup.tab.prevent in vue cannot prevent tab browser default events

related codes

@keyup.stop.prevent="onKeyup"

methods: {
    onKeyup(e){
        e.preventDefault();
        switch (e.keyCode) {
          // tab
          case 9:
             ......
        }
        return false 
    }
}

as in the code above, keyup is bound in template and also specifies that e.preventDefault () and return false, are also used in the modifier prevent,onKeyup method, but neither prevents the default event of the tab key.

is there any other solution?


//        
    $(document).ready(function () {
        $(document).bind('keydown', function (event) {
            if (event.keyCode == 9) {
               return false;
            }
        });
    });

ask the same question: want to write the ES6+AMD specification


advance the timing of preventDefault to keydown


actually, the default tab of the browser is the keydown event, and your prevent on keyup is invalid, as are some other events such as ctrl+s.

Menu