I have a motor which its output shaft has a key, and it will be connected to a wheel/tyre. I'm wondering how can I lock the hub axially, so there is no way it can move freely along the axis, which could mean that eventually the wheel-tyre could go off. I'm not sure if a split coupling with a keyway a could work, but I doubt it's designed to press the key and restrict axial movement. Any ideas/suggestions, thanks :)
In modern automobiles, this age-old problem has been solved by using flanged coupling between wheel and driveshaft (This also facilitates easy Stepney replacement).
The reduction box in your comment led me to do some google searches. I found this This is split-half coupling a standard component in boats. Since it doesn't come very cheap I would suggest to make CAD to your required dimensions 3D print it and then use grub/set screws instead of a key.
Do let me know if there are any issues