A relatively simple question of what two unity functions are called

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.

Maybe you should break this into smaller Qs.

The “intellisense” feature is known to fall off sometimes. There are Answered Qs here about how to get it working again.

I think you want to know whether DisableKey is a Unity function, or if it’s been renamed? I think another short Q (with DisableKey) in the title, might be better for that. BUT:

DisableKey is just a very strange function written by this angryAnt person, as a joke (whenever someone starts with “I suppose you could…”.) Since it’s written out, you 100% know it’s not in Unity (that’s just basic programming, which you can learn from any book.)

Ok I tried to make my own function using EventType.Ignore to ignore certain keyboard buttons, but I missed some details to get it to work.

if ((Input.GetKeyDown(KeyCode.LeftArrow)) || (Input.GetKeyDown(KeyCode.RightArrow)) || (Input.GetKeyDown(KeyCode.UpArrow)) || (Input.GetKeyDown(KeyCode.DownArrow)) ||
(Input.GetKeyUp(KeyCode.LeftArrow)) || (Input.GetKeyUp(KeyCode.RightArrow)) || (Input.GetKeyUp(KeyCode.UpArrow)) || (Input.GetKeyUp(KeyCode.DownArrow)) ||
(Input.GetKeyDown(KeyCode.A)) || (Input.GetKeyDown(KeyCode.D)) || (Input.GetKeyDown(KeyCode.W)) || (Input.GetKeyDown(KeyCode.S)) ||
(Input.GetKeyUp(KeyCode.A)) || (Input.GetKeyUp(KeyCode.D)) || (Input.GetKeyUp(KeyCode.W)) || (Input.GetKeyUp(KeyCode.S)))
{

            EventType.Ignore;

What I want to do is to use code like

float moveHorizontal = Input.GetAxis(“Horizontal”);

    float moveVertical = Input.GetAxis("Vertical");
    Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

    Vector3 newVelocity = new Vector3(movement.x * speed + movement.x * moveDirection, 0f, movement.z * speed);
    GetComponent<Rigidbody>().velocity = newVelocity;

which increases the speed of the player ship when it hits something (in addition to some strange behaviour which includes not preventing the player ship from overlapping the enemies from the code (movement.x*moveDirection)) together with the code

public IEnumerator MoveRight(int moveDuration)
{

    turbulenceDirection += turbulenceSpeeds;
    while (turbulenceDuration > 0)
            (the new code is placed here)
    {
        yield return new WaitForSeconds(1f);
        turbulenceDuration--;
    }
    turbulenceDirection = 0.0f;
}

What I want to do is to turn off listening to the same buttons as the program listens to for normal movement such that the program no longer listens to those buttons, and the program can then get input from another source as in (transform.rightspeed). Normally getting input to movement from two different sources will get the program to crash, but I try to turn off listening to all the same buttuns as Vertical and Horizontal uses and then no input is given to the program for movement from that part of the program and it get no conflict with adding a (transform.rightspeed) and (-transform.right*speed) when the program is not listening to normal movement, performing the alternative movement, stop executing the alternative movement and then start listening to normal movement again.

If the main thought of how I think Unity functions regarding to why the program crashes when two different input is used for the same movement is correct and how it is possible to only use one of the two inputs in each frame please confirm and tell me what code is missing to get it to work, if I have misunderstood something of how Unity functions in this situation please tell me how it should be done. Most likely the only change I have to do is changing EventType.Ignore into one or two lines of code. Please explain the last details.
If relevant I have tried to get the game behavior of pushing the player ship to the left or right (depending on which side of the enemy the player ship hits of the two possibilities left and right) instead of actually overlapping an enemy when the player ship touches an enemy (which conflicts with the normal movement), for several months or something, and it will be very satisfying when I finally get it to work, and I am quite sure the correct solution is to turn off listening to the normal movement use transform.right*speed as alternative movement turn off alternative movement and start listening to normal movement again. Thank you.