in a demented manner; in a way that shows loss of sanity or mental control.
From 'demented' + '-ly' (adverbial suffix). This creates an adverb describing actions performed with lost mental faculties.
Adding '-ly' to 'demented' shows how English lets us describe not just a state (mad) but the way actions happen in that state (demented laughter, dementedly dancing).
Complete word intelligence in one call. Free tier — 50 lookups/day.