1

Is it possible for the browser to access clipboard when user presss CTRL + C? Using pure Javascript approach.

The idea being, I have a web application that needs to be able to access the clipboard when user press the key combination.

  • 1
    as far as I'm aware you need to use flash for clipboard access – DdD Dec 08 '14 at 00:21
  • @DimitriAdamou and what about do this without flash? – user2513522 Dec 08 '14 at 00:24
  • See [`ClipboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent) at MDN. – Oriol Dec 08 '14 at 00:26
  • Although re-reading your question, you can just do an event that raises on ctrl + c and do your stuff (without accessing the clipoard) http://stackoverflow.com/questions/4604057/jquery-keypress-ctrlc-or-some-combo-like-that – DdD Dec 08 '14 at 00:28
  • @DimitriAdamou i need a data(link) that locate in clipboard – user2513522 Dec 08 '14 at 00:30
  • There are apparently events such as oncopy, onpaste eg ``. Try look at this https://gist.github.com/umidjons/8612712 While not direct access to clipboard, you can at least modify what goes there – DdD Dec 08 '14 at 00:33
  • possible duplicate of [Is it possible to read the clipboard in Firefox, Safari and Chrome using Javascript?](http://stackoverflow.com/questions/233719/is-it-possible-to-read-the-clipboard-in-firefox-safari-and-chrome-using-javascr) – abl Dec 08 '14 at 03:16

1 Answers1

0

You can use the navigator clipboard.

Note: You must preview it directly to browser when you are using Phone.

Look! this is all navigator.clipboard functions:

navigator.clipboard >
|—— read
|—— readText
|—— write
|—— writeText

to write a text to the clipboard. to this!

navigator.clipboard.writeText("Hello World!");

Note: the object clipboard is a Promise {}