This is a funny one, and there are a number of reasons as to why they might do that. Some people think it’s because keyboards are quite warm, and as cats can be a heat-seeking species, they enjoy sitting on a warm surface.
It’s also a way for cats to solicit attention and get a bit of time with their owners. By stopping the owner from working, the cat gets something nice from their owner in return in the form of attention, time, fuss, strokes, etc.
A cat will always do what works, so once they’ve learnt that behaviour will result in something that they want, the behaviour is rewarded and reinforced – and so they’ll repeat the behaviour in the future.
Cats as a species tend to prefer low intensity high frequency physical contact, so a lot of cats like to be near their owners, but may not necessarily enjoy sitting in a person’s lap. Sitting on the keyboard close to their owner allows them to enjoy your company and enjoy being near you.
A keyboard or laptop is also very much the focus of attention for the owner while they’re using it. It could be that some cats may appreciate the importance of it to the owner, and so they want to focus on it as well – almost “it’s important to you so it’s important to me too”.
So they’re not just being a pain in the butt!
Sue is Feline Welfare Manager for Battersea Dogs & Cats Home.