You might think petting a cat should be a straightforward exercise, but you’d be wrong. There’s actually a science behind petting a cat so you can withdraw your hand safely without blood pouring from an open wound.
The key is to provide the cat with as much choice and control during interactions as possible. Research shows interactions with cats are likely to last longer when the cat initiates the petting rather than when the human tries to do it.
So pet your cat using the scientific method of letting your cat get what it wants when it wants it. That will always please your cat no matter what you may be doing.