How to allow both keyboard and joystick controller as input in a same scene. and yes, based on priority the other input should get locked.
By default, your project should be able to detect both keyboard and joystick input. See here and here for more info.
As for locking out one or the other, you can use the answer provided here as a starting point, and then block the input not being used.
Ideally, you would want some way of switching between the two, like using the first command from the locked controller to unlock it and then handle input normally. Some games don't block, but rather let the user switch seamlessly between input types and update the UI accordingly. In the end it all depends on your game and what works best for you.