Socket
Socket
Sign inDemoInstall

@imshann/event

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @imshann/event

event handler


Version published
Maintainers
1
Install size
40.7 kB
Created

Readme

Source

@imshann/event

a event library.

import

import { watchEvent, EventName } from "@imshann/event";

TextSelectStart

watchEvent(
  EventName.TextSelectStart,
  document.querySelector("#box"),
  (event) => {
    console.log(event.getSelectedText());
  }
);

TextSelectOver

watchEvent(
  EventName.TextSelectOver,
  document.querySelector("#box"),
  (event) => {
    console.log(event.getPosition()); // => { x: 11, y:22 }
  }
);

TextSelectEnd

watchEvent(EventName.TextSelectEnd, document.querySelector("#box"), (event) => {
  console.log(event.getSelectedText()); // => abc
});

paste

watchEvent(EventName.Paste, document.querySelector("#editor"), (event) => {
  console.log(event.getClipboardData());
  event.preventDefault();
});

input

The following callback function will be called when the user enter the "a-zA-Z0-9~`!@#$^%&*()_-+={}[]|:;"'<,>./?" range character.

watchEvent(EventName.Input, window, (event) => {});

compositionstart

watchEvent(
  EventName.CompositionStart,
  document.querySelector("#input"),
  (event) => {}
);

compositionend

listen for chinese input events.This event function is called after inputting chinese.

watchEvent(
  EventName.CompositionEnd,
  document.querySelector("#input"),
  (event) => {
    // get the input chinese text
    event.getData();
  }
);

FAQs

Last updated on 24 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc