Hans Beckert is the main character of the 1931 film M. He is a mentally disturbed pedophile and child killer who genuinely cannot stop himself from doing what he does and is haunted by guilt. He was played by Peter Lorre. Hans is also known for whistling the tune of "In the Hall of the Mountain King" throughout the film.
In the film's first scenes he is seen luring a little girl to him with a balloon and killing her offscreen. Later, police investigations are shown establishing that there is a serial child killer on the prowl and the local organized criminals are also looking for the killer not only because his crimes are disgusting even to them but because his presence in town has led to more police patrolling the streets, which is bad for their "business". One criminal identifies Hans as the killer with some help from the balloon salesman from the beginning, and marks his jacket with the letter "M" so his associates can track him.
After causing some chaos while trying to follow him, the criminals capture Hans and put him on "trial" amongst their kind, expecting to kill him no matter what he says. Hans attempts to defend himself by pleading insanity, and claims that he is not necessarily much worse than the other criminals because while he really cannot control the horrible things he does, they commit their crimes because they aren't willing to make an honest living. The criminals, of course, don't want to admit this and proceed to attempt to kill Hans, but the police arrive just in time and they are all arrested.
The film ends before the real court of law declares Hans' sentence.