Make something happen when I press a key?

I'm somewhat new to RPG maker MV but I want to know something.
How do I make it so when I press the 9 key It transfers me into a certain area.
Also how do I make it so there are certain areas where the 9 key doesn't transfer me.
Thanks
Yanfly's "Button Common Events" plugin will let you do this - you can set it up so that when the player presses 9 on the keyboard it will run a Common Event, then have the Common Event check if you are in an area where you can be transferred from, and either transfer you or not.

Original thread: https://forums.rpgmakerweb.com/threads/make-something-happen-when-i-press-a-key.154273/