'Can't save xdotool output in a variable or a file

I am simulating a keypress event that gives some text output on the terminal.

For ex - command - "xdotool key d" gives some string output on terminal -

But I cannot save it in the file. What's the issue and how to do this?

# xdotool key d > output.txt



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source