Clipboard input in many devices is not detected as paste
Did you clear cache before opening an issue?
- [x] I have cleared my cache
Is there an existing issue for this?
- [x] I have searched the existing open and closed issues
Does the issue happen when logged in?
Yes
Does the issue happen when logged out?
Yes
Does the issue happen in incognito mode when logged in?
Yes
Does the issue happen in incognito mode when logged out?
Yes
Account name
aaryandadu
Account config
No response
Current Behavior
when using monkeytype on many devices text inserted via the clipboard is not detected as a paste action thus leading to absurd results. This most probably caused because clipboard based input method does not trigger OS level paste event that the event listeners listens for.
https://github.com/user-attachments/assets/511a07f5-cf57-47ed-b336-f653314f244a
Expected Behavior
This type of paste by the clipboard should be disabled. I looked into the possible solutions we can move towards but I think that the better approach would be to detect max 1 character per keystroke, multiple characters in one key stroke could be blocked.
Steps To Reproduce
- Use Gboard in any device or built-in clipboard by One UI.
- Copy the text from the preview in monkeytype in any mode
- Paste the copied text using the clipboard
https://github.com/user-attachments/assets/b6b7abc3-b5d8-46ab-a490-383128a217ec
Environment
- OS:
- Browser:
- Browser Version:
Anything else?
No response
I can reproduce this on mobile (Gboard / One UI). It looks like clipboard insertion often doesn’t trigger a native paste event, so Monkeytype treats it like normal typing.
Before opening a PR, my plan is to block any “bulk insert” at the input layer: listen to beforeinput and prevent events like insertFromPaste and any insertText where e.data.length > 1. As a fallback for devices that bypass beforeinput, we can detect sudden value jumps in input and revert. This should reliably disable clipboard pastes across mobile keyboards without relying on OS paste events.
I can reproduce this on mobile (Gboard / One UI). It looks like clipboard insertion often doesn’t trigger a native paste event, so Monkeytype treats it like normal typing.
Before opening a PR, my plan is to block any “bulk insert” at the input layer: listen to beforeinput and prevent events like insertFromPaste and any insertText where e.data.length > 1. As a fallback for devices that bypass beforeinput, we can detect sudden value jumps in input and revert. This should reliably disable clipboard pastes across mobile keyboards without relying on OS paste events.
I don't know why the monkeytype has been designed in such a way to accept burst insert as input so will have to look and discuss about it, so its better not to jump to PR right now
I can reproduce this on mobile (Gboard / One UI). It looks like clipboard insertion often doesn’t trigger a native paste event, so Monkeytype treats it like normal typing. Before opening a PR, my plan is to block any “bulk insert” at the input layer: listen to beforeinput and prevent events like insertFromPaste and any insertText where e.data.length > 1. As a fallback for devices that bypass beforeinput, we can detect sudden value jumps in input and revert. This should reliably disable clipboard pastes across mobile keyboards without relying on OS paste events.
I don't know why the monkeytype has been designed in such a way to accept burst insert as input so will have to look and discuss about it, so its better not to jump to PR right now
Makes sense. I won’t jump into a PR yet. If you decide burst inserts should not count as normal input, I am happy to help with an approach that blocks beforeinput paste-type inserts and adds a small fallback for mobile keyboards that bypass native paste events. Just let me know what direction you want to take and I can adjust accordingly.
I would probably guess Android simulates each keypress instead of sending a paste event. Can you test on https://events.monkeytype.com/ ?
I would probably guess Android simulates each keypress instead of sending a paste event. Can you test on https://events.monkeytype.com/ ?
From this I don't think android simulates each keypress if it would have then multiple entries for each character of "pasted" should have come, right?
I would probably guess Android simulates each keypress instead of sending a paste event. Can you test on https://events.monkeytype.com/ ?
![]()
From this I don't think android simulates each keypress if it would have then multiple entries for each character of "pasted" should have come, right?
Looks like it simulates the whole word incoming at once, but its using the wrong event type - it should be insertFromPaste. Looks like, as usual, Android is being different for the sake of it. Not sure if this is fixable without affecting other things.
But if it would have been Android specific I don't think it would be reproducible in iOS but it is as I have shown in the video provided in the Steps to Reproduce section of this issue.
This is the result for iPhone 14 iOS version 18.6.2 Browser Safari using Google's GBoard
Some research revealed this to me which hints that these operations are at IME level
According to ChatGPT interaction between keyboard input and browser differs here: IMEs (like Gboard) emit text commits Browser receives plain text insertion
User action (tap / swipe / paste / voice)
↓
IME (keyboard app)
↓
OS input system
↓
Browser
↓
DOM input events
So yeah fixing it might affect others as still the only solution I could think of is limiting the max character insertion to 1 per 'insertText' But also if we will leave it unfixed, this bug can be exploited in some manner by others affecting the overall stats
But if it would have been Android specific I don't think it would be reproducible in iOS but it is as I have shown in the video provided in the Steps to Reproduce section of this issue. This is the result for
iPhone 14 iOS version 18.6.2 Browser SafariusingGoogle's GBoard
GBoard issue then.
So yeah fixing it might affect others as still the only solution I could think of is limiting the max character insertion to 1 per 'insertText' But also if we will leave it unfixed, this bug can be exploited in some manner by others affecting the overall stats
It can be exploited because with keydown and keyup events missing, anticheat will be triggered.
So yeah, nothing that can be done on my side if GBoard is simply not sending the correct event type as it should. The acual insertFromPaste event is already blocked in the input system.
From this I don't think android simulates each keypress if it would have then multiple entries for each character of "pasted" should have come, right?