Insects are good examples of ground locomotion because they can adapt their gait pattern to propel them in any direction, over uneven terrain, in a stable manner. Nevertheless, replicating such locomotion skills to a legged robot is not a straightforward task. Different approaches have been proposed to synthesize the gait patterns for these robots; each approach exhibits different restrictions, advantages, and priorities. For the purpose of this document, we have classified gait pattern generators for multi-legged robots into three categories: precomputed, heuristic, and bio-inspired approaches. Precomputed approaches rely on a set of precalculated motion patterns obtained from geometric and/or kinematic models that are performed repeatedly whenever necessary and that cannot be modified on-the-fly to adapt to the terrain changes. On the other hand, heuristic and bio-inspired approaches offer on-line adaptability, but parameter-tuning and heading control can be difficult. In this document, we present the K3P algorithm, a real-time kinematic gait pattern generator conceived to command a legged robot. In contrast to other approaches, K3P enables the robot to adapt its gait to follow an arbitrary trajectory, at an arbitrary speed, over uneven terrain. No precomputed motions for the legs are required; instead, K3P modifies the motion of all mechanical joints to propel the body of the robot in the desired direction, maintaining a tripod stability at all times. In this paper, all the specific details of the aforementioned algorithm are presented, as well as different simulation results that validate its characteristics.