GoogleChromeLabs / GoogleChromeLabs/squoosh

Consider adding a `'paste'` event listener so that Cmd-V can paste images without permissions prompt

Open
#1,237 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
25.9k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

Currently, clicking "paste" triggers a clipboard permissions prompt. It'd be nice if just hitting Cmd-V (or Edit->Paste) in the browser would work too.

**Describe the solution you'd like**

Add something like this:

```
window.addEventListener('paste', event => {
let file_input = document.querySelector('#file'); // Whatever your internal file input object's id is
file_input.files = event.clipboardData.files;
file_input.dispatchEvent(new Event('change'))
});
```

With this, I can Cmd-C a file in Finder on macOS and then Cmd-V it in webapps that have that snippet.

**Does other service/app have this feature?**
My little image input tech demo has it: https://github.com/nico/hack/blob/main/cam/cam-param.html#L22

In general, many applications allow pasting images, of course.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.