How to check if the player pressed a key to move?

Hi, I am creating a script to move a player using pathfinding and I want to stop moving the player to that point when he presses a key to move. I’m not sure how to do that, I have tried using something from UserInputService | Roblox Creator Documentation like UserInputService | Roblox Creator Documentation or UserInputService | Roblox Creator Documentation but that won’t work on some devices and it’s not very efficient. I want to know if there is another way to do it so that I can detect it better. Like what Roblox’s click-to-move mode does.

have you tried ContextActionService | Roblox Creator Documentation
you can bind multiple keys with this including controller inputs, and also create buttons for mobile