I am quiet new to Javascript and so I decided to make a shortcut key userscript for m.youtube.
It does work but when I am using that shortcut(Ctrl+Z to undo text) in a text field for writing a comment this happens
My first thought is to use a different shortcut combination. Ctrl-Z is pretty standard for undo and you should probably not hijack a common shortcut for your own use or you run into issues like this. Perhaps add another key, such as Ctrl+Alt+Z.
I suppose you could look at the event target and if it is an input that receives text then you could just ignore it.