SYDNEY, Australia — With much of the globe under stay-at-home orders, police officers are becoming the enforcers of a new coronavirus code that demands what humans naturally resist: complete isolation and obedience.

Empowered by tough new laws and public pressure, police forces are testing how far to go in punishing behavior that is ordinarily routine. In Australia, the authorities have threatened people sitting alone drinking coffee with six months in jail. In Britain, the police came under fire for using a drone to film and shame a couple walking their dog on a secluded path.

But in other countries, enforcement has been much more aggressive and escalated into serious violence. In Kenya, officers are under investigation in multiple cases, including the death of a teenager shot while standing on a balcony during a dusk-to-dawn curfew. The police also used tear gas and batons on passengers at a ferry terminal and are being investigated in at least two other deaths, leading President Uhuru Kenyatta to say he regretted the violence.

In the Philippines, President Rodrigo Duterte on Wednesday ordered the police and the military to shoot anyone who “causes commotion,” after 20 protesters were arrested as they demanded food during the country’s lockdown.