Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@keydown.tab captures shift + tab too #5111

Closed
grofzero opened this issue Mar 6, 2017 · 3 comments
Closed

@keydown.tab captures shift + tab too #5111

grofzero opened this issue Mar 6, 2017 · 3 comments

Comments

@grofzero
Copy link

grofzero commented Mar 6, 2017

@keydown.tab captures shift + tab too. Is this the expected behavour? If it's a bug, I'll make a repro.

@posva
Copy link
Member

posva commented Mar 6, 2017

Yes, it's expected. You should explicitly check that shift is not pressed

@posva posva closed this as completed Mar 6, 2017
@agm1984
Copy link

agm1984 commented Mar 14, 2019

Here is the solution markup to accomplish this:

<your-element @keydown.tab="handleTabPress(someData, $event)"></your-element>

Inside the handler function, you can detect if SHIFT is held by examining the $event:

handleTabPress(someData, e) {
    // if SHIFT key is held to navigate backwards, exit through this gate
    if (e.shiftKey) {
        console.log('halting event due to SHIFT+TAB');
        return;
    }

    // otherwise, execute normal logic
    console.log('tab was pressed', someData);
},

@bigrepository
Copy link

Just to update this, since 2.5.0 vue has the .exact modifier, that prevents exactly this behaviour:

@keydown.tab.exact="dostuff()"

This will only work when tab is pressed, not when shift + tab ist pressed. See https://vuejs.org/v2/guide/events.html#exact-Modifier for more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants