How to record key pressed into text file

I want to detect if a letter key is pressed and save in notepad file.

Not exactly sure what you’re looking for. You should look into FileSystemWatcher class from C#. It will raise events whenever a specific file is modified.

However, this will pretty much only look at when a file is saved down, then it will raise the changed event. You’re going to have to get something much trickier going if you need it to be live. Probably a constant check against the contents of the file.

Check Input.inputstring in the doc to get any input key pressed

and to save : create text file in C#. - Questions & Answers - Unity Discussions