Locked and hidden cursor doesn't stay hidden

I have this script, the actual locking of the cursor is fine, it stays in the center and doesnt move, however the hiding of the cursor appears to be hidden, but whenever you press ANY key on the keyboard, it flickers(probably for a single frame), and then it goes hidden again. However when you are playing an fps and you are constantly pressing buttons, it constantly flickers and flickers. Here is the script, am I doing something incredibly idiotic or is there an underlying problem?

	//Locking the cursor
		Cursor.lockState = CursorLockMode.Locked;
		Cursor.visible = false;
		Cursor.lockState = CursorLockMode.None;
		Cursor.visible = true;

You could also try this one which I use by the way ,its the simplest and most used I belive.

function Start () {

Screen.lockCursor = true;


It will lock your cursor by default in the program version and you attach the script to the player camera also if you press esc ,it will unlock the cursor.