Help Desire Z touchscreen laggy and stuck keypresses


I hope someone can help me with this. When using the touchscreen with the physical keyboard folded in it is really laggy. Keypresses get stuck sometimes, so typing does not really work well. Sometimes a short tap to start an app will instead result in moving the icon.

Weird thing is that the problem is gone when I open the keyboard. Everything runs smooth then.

I just did a wipe to factory default, didn't help though.