I tried to use code found in the Unity community to turn of certain keyboard buttons, do an action which would conflict with the keyboard input which should be turned off while this conflicting action (movement) is done and turned back on afterwards, the relevant code looks as I found it before I tried to figure out how to make it work. The part that does not function is the word “key” in the third line. I guess the solution is that key should be removed and replaced by some function which takes a parameter as shown and what it does is to disable the relevant keyboard key as defined when the function is called, and a nearly identical method just with another name to undisable the same keyboard key. If this is correct the only information I need is what the functions are called which should be possible to look up in the documentation (look below).
If relevant most of this code is taken from a forum post written by AngryAnt, but it does not function as it stands.
void DisableKey(KeyCode key)
{
if (Event.current.keyCode == key (Event.current.type == EventType.KeyUp || Event.current.type == EventType.KeyDown))
{
Event.current.Use();
}
}
void Somemethod()
{
DisableKey(KeyCode.A);
DisableKey(KeyCode.D);
DisableKey(KeyCode.W);
DisableKey(KeyCode.S);
}
The main problem is that when I started using Unity I could write for example “transform” mark it and press control + ’ and get to a table with possible documentation where the top documentation almost always led to a description of the component with all possible functions and similar which could follow for example “transform.” where I could take a closer look on one or more of them and get a usually pretty good description of what the function does and not least what it is called as name. Now control + ’ has no effect at all in a script and if I open the documentation and searches for it manually I always get only irrelevant results compared to what I was looking for and the documentation I just described is not among any of the results, not even “transform” which I am quite sure I searched and found that documentation when I started using Unity has this documentation among the alternatives now which means the documentation is completely useless as the situation is now. If someone could tell me how to get the documentation to function as I earlier have used it myself and is used in the tutorals in Unity for the future, it is more likely than unlikely that I can find the answer to this question myself, but if someone has a good answer I will appreciate that answer too, thanks anyway.