Lock Mouse In Editor

Hello, I have a question about the editor, When you right click on the viewport the mouse locks to the screen and you can look around like a first person game. I was wondering how I could change it from right click to z. I want to press z over the view port to lock the mouse and z again to unlock it, How do I do that?