Search code examples
javascriptnode.jsrparobotjs

Instantly type in keyboard using JavaScript


I'm currently developing a RPA application. I need to type a text in keyboard, but I need this process to be executed instantly (as if it were a copy and paste).

I've tried Nut.js and Robotjs but both of these have a delay between one key and another even if I configure the delay to 0ms or 1ms.

Someone know another automation library to make this process of typing immediate? Or should I try Python?


Solution

  • You could use the pyperclip library to first copy text using the pyperclip.copy() function and then use PyAutoGui library to paste the text. The pyperclip doesn't have a built-in function to paste but using both of these we can make it work.

    Example:

    import pyperclip
    import pyautogui
    
    #copy text to clipboard
    text = "Testing the copy and paste"
    pyperclip.copy(text)
    
    #paste text from clipboard
    pyautogui.hotkey('ctrl', 'v')