npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-enter-to-tab

v3.1.5

Published

[![npm package][npm-img]][npm-url] [![Release](https://github.com/l3d00m/vue3-enter-to-tab/actions/workflows/release.yml/badge.svg)](https://github.com/l3d00m/vue3-enter-to-tab/actions/workflows/release.yml) [![ci](https://github.com/l3d00m/vue3-enter-to-

Downloads

14

Readme

vue3-enter-to-tab composable

npm package Release ci

A Vue 3 composable to convert enter key to tab key. Especially useful when inputting forms using a numpad.

This is a fork of ajomuch92/vue-enter-to-tab and has been converted from a Mixin to a Vue3 composable. It also features new options.

Install

Requires Vue >=3.3 and Node >=18.

# npm
npm i --save vue3-enter-to-tab
# yarn
yarn add vue3-enter-to-tab

Usage

Minimal example with composition API

<template>
  <div ref="form"></div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useEnterToTab } from 'vue3-enter-to-tab'

// Get ref to the parent element
const form = ref<HTMLElement | null>(null)

useEnterToTab(form)
</script>

Full example

See documentation below.

<template>
  <div ref="form">
    <input />
    <input v-prevent-enter-tab />
  </div>
</template>

<script setup lang="ts">
import { useEnterToTab } from 'vue3-enter-to-tab'
import { ref } from 'vue'

const form = ref<HTMLElement | null>(null)
const { vPreventEnterTab, isEnterToTabEnabled } = useEnterToTab(form, {
  autoClickButton: false,
  initialState: false,
})
// Read and change the status using that ref
isEnterToTabEnabled.value = true
</script>

Minimal example with options API

The code has not been tested yet and it is recommended to use the composition API instead.

<template>
  <div ref="form"></div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import { useEnterToTab } from 'vue3-enter-to-tab'

export default defineComponent({
  setup() {
    useEnterToTab(this.$refs.form)
  },
})
</script>

API: useEnterToTab(element, options?)

Input element

Type: HTMLElement | null

The parent element. This is where the event listener will be attached.

Enter key will be converted for all children input of this element, except for those with the v-prevent-enter-tab directive and not including <textarea>.

Input options

interface UseEnterToTabOptions {
  autoClickButton?: boolean
  initialState?: boolean
}

autoClickButton

If the next element is a button, it will be clicked. Activating this has the advantage that it's not necessary to press enter twice to click a button (often to submit the form).

Disable this if you don't want to click buttons automatically and instead just focus them like other inputs.

Default: true

initialState

Initial state of the function.

Default: true

Output vPreventEnterTab

Directive to use in those inputs you want to avoid use enter as tab. Inputs with this directive will act as normal when pressing enter.

Output isEnterToTabEnabled

Ref to read and change the status of the function.