I'm looking for a simple way to run my own function if player press any key (any mean really any that game can read, for example "Del", "F1-F12", "Tab" and so on... i think only "Fn" key is not readable by default.
First i tried to use this code:
WorldFrame:SetScript("OnKeyDown", Test);-- Or UIParent:SetScript("OnKeyUp/Down", Test);
But it freeze all input from my keyboard to game - other words, i can't move my character, every keypress print "Test" in chat, so i can control game only with mouse. Any solutions?
PS. I don't care about what key has been pressed, i just need run function Test() if any key was pressed.
You should definitely not use SetScript on frames that aren't your own, rather use HookScript, as it will append the script snippet with your code rather than replacing the original script function. Having that said, I don't think it's generally a good idea to hook shit onto the WorldFrame. You could just create your own invisible frame and have it propagate the keyboard input instead. Like this:
local f = Test or CreateFrame("Frame", "Test", UIParent)
localfunction TestPrint(self, key)
Also, get in the habit of localizing your functions.