OS:
- windows 8.1 embedded
- ubuntu 18.04
Unity version:
Hello. Unity has a performance issue. If I press and hold any keyboard button, fps will be halved. It doesn’t matter which project I use. I can create an empty project, open an empty scene, hold down any keyboard button - fps will drop almost twice. Has anyone else encountered this problem?
The problem exists in the editor and in the release build
Buttons like CAPS LOCK or CTRL do not lower fps.
The solution from the link doesn’t work for me, but the problem is similar: Why does holding down any button cause ~20-30 FPS loss? - Questions & Answers - Unity Discussions
There is no such problem in godot 3.2.3 
This is not normal and there’s something wrong with your Input code. Sounds like you are doing something in your code every frame if a key is depressed. Input.GetKeyDown returns true only in the frame when the player first depresses the key, and you should use GetKeyDown and GetKeyUp in some kind of if-statements to capture these events. Make sure you are performing the check from your Update function to be sure to actually capture it.
Here’s one way to handle your input, using delegate methods.
private delegate void InputHandler(KeyCode code, bool down);
private Dictionary<KeyCode, InputHandler> KEYS = new Dictionary<KeyCode, InputHandler>();
void Start() {
KEYS.Add(KeyCode.Q, RotationKeyPressed);
KEYS.Add(KeyCode.E, RotationKeyPressed);
KEYS.Add(KeyCode.K, GrenadeKeyPressed);
}
public void Update() {
RegisterKeyPress(KEYS);
}
private void RegisterKeyPress(Dictionary<KeyCode, InputHandler> keySet) {
foreach (KeyCode keyCode in keySet.Keys) {
if (Input.GetKeyDown(keyCode)) {
keySet[keyCode](keyCode, true);
}
if (Input.GetKeyUp(keyCode)) {
keySet[keyCode](keyCode, false);
}
}
}
private void RotationKeyPressed(KeyCode code, bool down) {
if (down)
// respond to rotation key down
else
// respond to rotation key up
}
private void GrenadeKeyPressed(KeyCode code, bool down) {
// etc
}
Wow! Thanks, this is great code but it didn’t help. 
Maybe I should try the Input system: https://docs.unity3d.com/2021.1/Documentation/Manual/com.unity.inputsystem.html
Nope. It didn’t help either. I don’t know what to do.
Then your movement/action code is such that during keypress you do something unnecessarily heavy (approximate pi) every frame
As I said before, an empty scene (without scripting) shows the same result.
So far, I have configured all controls for the mouse. It will do for now.
Yeah well, we are out of luck as I can’t hint to what could be wrong. I can just verify that for my 3D PC game there is no FPS impact either in editor or the actual game despite movement relies on key hold. This is just using the Input class.
On Ubuntu you can eg xev to see if OS keyboard events are firing while you run your editor and game. This shouldn’t be the case as your game/editor should have exclusive focus.