Repetitive or purposeless movements like shaking legs or banging head are called stereotype movements. It is a childhood behavioral disorder.
Stereotypic Movement Disorder - Causes, Symptoms, Diagnosis, and Treatment
The neurodevelopmental condition known as stereotypic movement disorder (SMD) is characterized by repetitive and dysfunctional motions.