Skip to content

⬅️ Back to Table of Contents

📄 directive.ts

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 3
📊 Variables & Constants 2
📑 Type Aliases 2

📚 Table of Contents

🛠️ File Location:

📂 packages/core/onKeyStroke/directive.ts

📦 Imports

Name Source
ObjectDirective vue
OnKeyStrokeOptions ./index
onKeyStroke ./index

Variables & Constants

Name Type Kind Value Exported
keys any const binding.arg?.split(',') ?? true
vOnKeyStroke `ObjectDirective<
HTMLElement,
BindingValueFunction BindingValueArray
>| const |{
mounted(el, binding) {
const keys = binding.arg?.split(',') ?? true
if (typeof binding.value === 'function') {
onKeyStroke(keys, binding.value, {
target: el,
})
}
else {
const [handler, options] = binding.value
onKeyStroke(keys, handler, {
target: el,
...options,
})
}
},
}`

Functions

mounted(el: any, binding: any): void

Code
mounted(el, binding) {
    const keys = binding.arg?.split(',') ?? true
    if (typeof binding.value === 'function') {
      onKeyStroke(keys, binding.value, {
        target: el,
      })
    }
    else {
      const [handler, options] = binding.value
      onKeyStroke(keys, handler, {
        target: el,
        ...options,
      })
    }
  }
  • Parameters:
  • el: any
  • binding: any
  • Return Type: void
  • Calls:
  • binding.arg?.split
  • onKeyStroke (from ./index)

Type Aliases

BindingValueFunction

type BindingValueFunction = (event: KeyboardEvent) => void;

BindingValueArray

type BindingValueArray = [BindingValueFunction, OnKeyStrokeOptions];