# ng-prevent-cut-copy-paste

> A package to prevent cut, copy and paste to input

Latest version **2.0.0** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng-prevent-cut-copy-paste
pnpm add ng-prevent-cut-copy-paste
yarn add ng-prevent-cut-copy-paste
bun add ng-prevent-cut-copy-paste
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-09-16 |
| First published | 2020-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dario E Gonzalez B |
| Maintainers | darioegb |
| Keywords | ng-prevent-cut-copy-paste, ng-prevent, angular prevent cut copy paste, angular directive, prevent clipboard |

## Links

- npm: https://www.npmjs.com/package/ng-prevent-cut-copy-paste
- Repository: https://github.com/darioegb/ng-prevent-cut-copy-paste
- Homepage: https://github.com/darioegb/ng-prevent-cut-copy-paste#readme
- Issues: https://github.com/darioegb/ng-prevent-cut-copy-paste/issues
- npm.io page: https://npm.io/package/ng-prevent-cut-copy-paste

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2026-09-16
- 1.1.2 — 2025-04-30
- 1.1.1 — 2022-01-20
- 1.1.0 — 2022-01-20
- 1.0.0 — 2020-06-01

## README

# NgPreventCutCopyPaste

## Features

- Directive that prevents cut, copy and paste on an input.
- Choose which events to block per element, or set a default for the whole app via a provider.

## Dependencies

Latest version available for each version of Angular

| ng-prevent-cut-copy-paste | Angular        |
| ------------------------- | -------------- |
| 2.0.0                     | >=20.0.0       |
| 1.1.2                     | 16.x to 19.x   |
| 1.1.1                     | 13.x 12.x 11.x |
| 1.1.0                     | 13.x 12.x 11.x |
| 1.0.0                     | 9.x 8.x 7.x    |

## Install

```bash
  npm install ng-prevent-cut-copy-paste --save
```

## Setup

Register the default configuration once, in `app.config.ts` (or `main.ts`):

```typescript
import { ApplicationConfig } from '@angular/core'
import { provideNgPreventCutCopyPaste } from 'ng-prevent-cut-copy-paste'

export const appConfig: ApplicationConfig = {
  providers: [provideNgPreventCutCopyPaste()],
}
```

The directive is standalone, so import it directly wherever you use it:

```typescript
import { NgPreventCutCopyPasteDirective } from 'ng-prevent-cut-copy-paste'

@Component({
  imports: [NgPreventCutCopyPasteDirective],
  // ...
})
export class LoginFormComponent {}
```

> `NgPreventCutCopyPasteModule` (with a `forRoot(config?)` method) is still available but **deprecated**; use `provideNgPreventCutCopyPaste()` instead.

## Use

After configuration you can used the directive as follow example

```html
<input
  type="password"
  formControlName="password"
  placeholder="Password"
  class="form-control"
  ngPreventCutCopyPaste
/>
```

By default all three events (`cut`, `copy`, `paste`) are blocked. Override them per element:

```html
<input ngPreventCutCopyPaste [ngPreventCutCopyPasteEvents]="['paste']" />
```

Or set an app-wide default via the provider:

```typescript
provideNgPreventCutCopyPaste({ events: ['paste'] })
```

## License

MIT

---

> GitHub [@darioegb](https://github.com/darioegb) &nbsp;&middot;&nbsp;

---
_Source: https://npm.io/package/ng-prevent-cut-copy-paste · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
