What is the TypeScript definition for the onCopyCapture event in React?
The right interface for onCopyCapture is ClipboardEvent
Please continue reading below to see how to use it or read my guide on using React events with TypeScript.
You can also go to the search page 🔍 to find another event.
You can access and manipulate the clipboard's data on specific user interactions through the clipboard event.
Besides the default values of any React event, this event also includes "clipboardData", which provides an interface for all the system's clipboard operations.
Interface
interface ClipboardEvent<T = Element> extends SyntheticEvent<T, NativeClipboardEvent> {
clipboardData: DataTransfer;
}
Full example
import React, { ClipboardEvent } from 'react';
const InputComponent = () => {
const handleClipboardEvent = (e: ClipboardEvent<HTMLInputElement>) => {
// Do something
};
return <input value="Some text" onCopyCapture={handleClipboardEvent} />;
};
export default InputComponent;