-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
keyboard type function doesn't type entire string at once #460
Comments
Hi @himat 👋 Just to make sure, which OS are you on? A simple workaround to this problem would be to use clipboard.copy("you string");
keyboard.pressKey(Key.LeftSuper, Key.V); // macOS
keyboard.releaseKey(Key.LeftSuper, Key.V); // macOS
// keyboard.pressKey(Key.LeftControl, Key.V); // For Windows and Linux
// keyboard.releaseKey(Key.LeftControl, Key.V); // For Windows and Linux Simon |
Thanks Simon Yeah that would work for me for now. Although I don't like the idea of replacing what's in the user's clipboard though every time. So I think it would be more sustainable to be able to directly paste the entire text just like how pasting from the clipboard does it. |
Hi @himat 👋 modifying the clipboard content is not ideal, yes, but if you really want to have instant pasting, this is the only way to go. I'll have a look at the behaviour you described, though. |
@s1hofmann yeah I think you're right. But then is there a way to do what the clipboard pasting does of entering in an entire piece of text at once that can be replicated without saving to the clipboard? |
I have also noticed this same behavior. If I had delay set to 20 ms it skipped the first three characters of what I was trying to type. This is on Windows 11. |
On MacOS 13 I have not noticed any skipping of letters when setting the delay to 0 const { keyboard } = require("@nut-tree/nut-js");
keyboard.config.autoDelayMs = 0;
(async () => {
await keyboard.type("my string");
})(); And I can paste from the clipboard const { clipboard, keyboard, Key } = require("@nut-tree/nut-js");
(async () => {
await clipboard.setContent("my string");
await keyboard.pressKey(Key.LeftSuper, Key.V);
await keyboard.releaseKey(Key.LeftSuper, Key.V);
})(); |
If you are planning to use the clipboard method to type the string all at once, you can store the initial value of the clipboard in a variable and then set it back to the initial value after your script is done executing |
Closed due to inactivity, feel free to re-open on updates. |
It seems the nut.js keyboard type function doesn't type the entire string at once like the
robotjs
one did?This is pretty inconvenient when you want to enter in an entire piece of text at once.
If you compare
vs
The first one types char by char which takes a while, whereas the second inputs the entire string instantly into whatever text box you're in.
I saw that I can configure the delay for nut
keyboard.config.autoDelayMs = 50;
But that parameter is not working well. At 100, it types correctly, but if I lower it to 50, I saw the first character was missing, and if I lowered it to 10, many characters were not typed.
Is there a workaround for this that makes the typing equivalent to the robotjs way?
The text was updated successfully, but these errors were encountered: