Shortcut keys don't work when v-textarea is focused
P粉415632319
P粉415632319 2023-09-10 20:28:59
0
1
411

I have a small question. Once the text area has focus, shortcut keys (plugins) cannot be executed on the button.

... => Irrelevant content

<template>
    <div>
        <v-textarea ... />
        <div>
            <v-btn
             v-shortkey="['esc']"
             @shortkey="abort"
            >
            ...
            </v-btn>
             <v-btn
              v-shortcut="['alt', 'enter']"
              @shortkey="confirm"
             >
             </v-btn>
        </div>
    </div>
</template>
<script>
    methods: {
        abort() {
            console.log('aborted')
        }

        confirm() {
            console.log('confirmed')
        }
    }
</script>

Neither of these methods will be executed when you are focused. Does anyone have a solution?

If you click "alt" and "enter" I want to execute the confirm method and even focus on the text area. If you click "esc" I want to execute the abort method and even focus on the text area.

P粉415632319
P粉415632319

reply all(1)
P粉057869348

One way to achieve this is to add an event listener in the js part of the component.

This will capture all keys pressed on the keyboard. You can check what keys were pressed by passing the parameters attached to the event.

NOTE This will not only listen to all keypresses while focused on the button/textarea.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!