JavaScript Element cut Event

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
DOM event
Instance event

What You’ll Learn

The cut event fires when the user starts a cut action in the browser UI. Learn clipboardData.setData, why preventDefault also blocks removal, selection.deleteFromDocument(), oncut, and five try-it labs.

01

Kind

Instance event

02

Type

ClipboardEvent

03

When

User cut action

04

Handler

oncut

05

Key APIs

setData + delete

06

Status

Baseline widely available

Introduction

Cut is like copy plus remove. When someone selects editable text and presses Ctrl+X (or Cmd+X), the browser fires cut, puts the selection on the clipboard, and deletes it from the page.

You can customize the clipboard payload with setData. If you also call preventDefault(), you must remove the selection yourself (usually selection.deleteFromDocument()) if you still want cut behavior.

💡
Beginner tip

Custom cut = setDatadeleteFromDocument()preventDefault(). Forget the delete step and the text stays in the field.

Understanding cut

An instance event that answers: “Did the user just start a cut action from the browser UI?”

  • Default — copy selection to clipboard and remove it from the document.
  • ClipboardEvent — write with clipboardData.setData(format, data).
  • CancelablepreventDefault() blocks clipboard default and document update.
  • Uneditable content — event may still fire, but often with no data.
  • Baseline Widely available on MDN (since July 2015).

📝 Syntax

Use the event name with addEventListener, or set the handler property:

JavaScript
addEventListener("cut", (event) => { });

oncut = (event) => { };

Event type

A ClipboardEvent (inherits from Event).

Key property

Property / methodMeaning
clipboardDataDataTransfer object for this clipboard operation
clipboardData.setData(format, data)Write a MIME type such as text/plain
Selection.deleteFromDocument()Manually remove the selection after cancelling default cut

⚖️ cut vs copy

Topiccopycut
ClipboardWrites selection (by default)Writes selection (by default)
DocumentLeaves text in placeRemoves selection
After preventDefaultCustom data onlyMust delete yourself if you still want removal
Typical shortcutCtrl/Cmd+CCtrl/Cmd+X

🔒 What You Can and Cannot Do

  • Can replace cut text with setData + manual delete + preventDefault().
  • Cannot read clipboard contents inside a cut handler.
  • Cannot change clipboard or document by only dispatching a fake cut event.
  • Siblingscopy and paste complete the clipboard story.

⚡ Quick Reference

GoalCode / note
Listenel.addEventListener("cut", fn)
Handler propertyel.oncut = fn
Custom cut textsetData + deleteFromDocument() + preventDefault()
Read selectiondocument.getSelection().toString()
MDN statusBaseline Widely available (Jul 2015)

🔍 At a Glance

Four facts to remember about cut.

Event type
ClipboardEvent

clipboardData

Default
copy + remove

From the document

Custom cut
setData + delete

Then preventDefault

Baseline
yes

Widely available

Examples Gallery

Examples follow MDN Element: cut event. Select text in an editable box, cut with Ctrl+X / Cmd+X, then paste.

📚 Getting Started

MDN-style custom cut and the handler property.

Example 1 — Uppercase cut (MDN)

Put an uppercase selection on the clipboard and remove it from the document.

JavaScript
const source = document.querySelector("div.source");

source.addEventListener("cut", (event) => {
  const selection = document.getSelection();
  event.clipboardData.setData("text/plain", selection.toString().toUpperCase());
  selection.deleteFromDocument();
  event.preventDefault();
});
Try It Yourself

How It Works

Without deleteFromDocument(), cancelling the default would leave the original text in the box while still writing custom clipboard data.

Example 2 — oncut Property

Same custom-cut pattern using the handler property.

JavaScript
const field = document.getElementById("field");

field.oncut = (event) => {
  const selection = document.getSelection();
  event.clipboardData.setData("text/plain", selection.toString());
  selection.deleteFromDocument();
  event.preventDefault();
};
Try It Yourself

How It Works

Prefer addEventListener when you need multiple listeners or easy removal.

📈 Log, Trim & Soft Block

Observe cuts, normalize text, or cancel cut for a demo field.

Example 3 — Log When Users Cut

Observe without changing default cut behavior.

JavaScript
const editor = document.getElementById("editor");
const out = document.getElementById("out");

editor.addEventListener("cut", () => {
  const len = document.getSelection().toString().length;
  out.textContent = "Cut " + len + " character(s)";
});
Try It Yourself

How It Works

Skipping preventDefault keeps the normal cut (clipboard + remove) while you log.

Example 4 — Trim Then Delete

Write trimmed text to the clipboard and remove the selection.

JavaScript
const field = document.getElementById("field");

field.addEventListener("cut", (event) => {
  const selection = document.getSelection();
  const text = selection.toString().trim();
  event.clipboardData.setData("text/plain", text);
  selection.deleteFromDocument();
  event.preventDefault();
});
Try It Yourself

How It Works

Transform first, delete second, cancel last—that order matches MDN’s teaching example.

Example 5 — Soft Block Cut

Cancel cut and leave the text in place—demo only, not security.

JavaScript
const secret = document.getElementById("secret");
const out = document.getElementById("out");

secret.addEventListener("cut", (event) => {
  event.preventDefault();
  out.textContent = "Cut disabled in this demo field.";
});
Try It Yourself

How It Works

Because default is cancelled, nothing is removed and nothing useful is written for the user. Prefer clear UX over fake DRM.

🚀 Common Use Cases

  • Normalizing cut text (uppercase, trim) before it hits the clipboard.
  • Cutting a plain-text version of a rich selection.
  • Logging when users cut content from an editor.
  • Softly blocking cut on a demo field (with clear UX).
  • Keeping cut/copy/paste handlers consistent in a custom editor.

🔧 How It Works

1

User starts Cut

Shortcut or menu command, usually on editable content.

Input
2

cut event fires

Bubbles; your listener can customize clipboardData.

Event
3

Default or custom path

Browser copies+removes, or you setData, delete, and cancel.

Action
4

Clipboard ready, field updated

Paste elsewhere; the original selection is gone (if cut succeeded).

📝 Notes

  • MDN: Baseline Widely available (since July 2015).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Cancelling default cut also cancels document removal—delete manually if needed.
  • Synthetic cut events do not update the clipboard or the document by themselves.
  • Related learning: copy, dblclick, addEventListener(), JavaScript hub.

Universal Browser Support

cut is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. Editable vs non-editable cut behavior can still differ by browser.

Baseline · Widely available

Element cut

Works across modern desktop and mobile browsers for user-initiated cut actions on editable content.

100% Widely available
Google Chrome Supported · Desktop & Android
Full support
Mozilla Firefox Supported · Desktop & Android
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Opera Supported · Modern versions
Full support
Internet Explorer Supported (legacy clipboard model)
Supported
cut Baseline

Bottom line: Listen for cut to customize outgoing clipboard text; after preventDefault, call deleteFromDocument if you still want the selection removed.

Conclusion

cut is the “user is cutting” signal. Customize with setData, remember that preventDefault also blocks removal, and call deleteFromDocument() when you still want the selection gone.

Continue with dblclick, copy, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Prefer addEventListener("cut", ...)
  • Use editable hosts (contenteditable / inputs) for real cut demos
  • Call deleteFromDocument() when cancelling a custom cut
  • Keep cut and copy transformations consistent
  • Learn paste for the inbound clipboard path

❌ Don’t

  • Forget that preventDefault also blocks removal
  • Expect to read clipboard contents in a cut handler
  • Assume a synthetic cut event updates clipboard or DOM
  • Treat cut-blocking as content protection
  • Overwrite oncut if you need multiple listeners

Key Takeaways

Knowledge Unlocked

Five things to remember about cut

Copy plus remove—customize with setData, delete manually after preventDefault.

5
Core concepts
📄 02

ClipboardEvent

clipboardData

API
📋 03

setData

custom payload

Pattern
🗑️ 04

deleteFromDocument

after preventDefault

Must
🎯 05

Baseline

widely available

Compat

❓ Frequently Asked Questions

It fires when the user starts a cut action through the browser UI (for example Ctrl+X / Cmd+X or Edit → Cut). The default action copies the selection to the clipboard and removes it from the document.
No. MDN marks Element cut as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
A ClipboardEvent. The important property is clipboardData, which you can write to with setData(format, data).
Cancelling the default also stops the browser from removing the selection from the document. If you still want a cut-like result, call selection.deleteFromDocument() yourself after setData.
Yes. The cut event can still fire, but the event may contain no clipboard data when the content is not editable.
No. Like copy, a cut handler cannot read clipboard data. You can write with setData after cancelling the default action.
Did you know?

MDN’s classic cut demo uppercases the selection, deletes it from the document, then cancels the default. Paste into another box and you get the uppercase text—while the source box no longer contains that selection.

Next: dblclick

Handle double-clicks for optional UI shortcuts.

dblclick →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful