Friday, October 24, 2025
HomeLanguagesWhat is onCutCapture Event in ReactJS ?

What is onCutCapture Event in ReactJS ?

React onCutCapture is an event handler that gets triggered whenever we cut a text. like oncut, but the difference is that onCutCapture acts in the capture phase whereas onCut acts in the bubbling phase i.e. phases of an event.

Prerequisite:

Syntax:

<input onCutCapture={function}/>

Creating React Application:

Step 1: Create a react project folder, for that open the terminal, and write the command npm create-react-app folder name. If you have already installed create-react-app globally. If you haven’t then install create-react-app globally by using the command npm -g create-react-app or can install locally by npm i create-react-app.

npm create-react-app project

Step 2: After creating your project folder(i.e. project), move to it using the following command.

cd project

Project Structure: It will look like this:

Ā 

Example: In this example, we are creating an input field with the default value ā€œCut the textā€. When we cut (Ctrl+X) a particular text in the input field the onCutCapture event will call onCutCaptureHandler, a function that will show the text ā€œCut the textā€ in the console.

App.js




function App() {
Ā Ā Ā Ā const onCutCaptureHandler = () => {
Ā Ā Ā Ā Ā Ā Ā Ā console.log("Cut the text");
Ā Ā Ā Ā };
Ā Ā Ā Ā return (
Ā Ā Ā Ā Ā Ā Ā Ā <div className="App">
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā <h1> Hey Geek!</h1>
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā <input
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā defaultValue="Cut the text"
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā onCutCapture={onCutCaptureHandler}
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā ></input>
Ā Ā Ā Ā Ā Ā Ā Ā </div>
Ā Ā Ā Ā );
}
Ā Ā 
export default App;


Step to Run the Application: Run the application using the following command from the project’s root directory.

npm start

Output:

Ā 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS