There are two approaches. One is avoiding the buildup of the charge; the other is discharging it so you cannot shock the cat or yourself.
The cat also builds up a charge, but because of its smaller size, most of the flow is from you to the cat.
In friction between any two materials with different affinities for electrons, one winds up negatively charged, with a surplus of electrons, and one positively charged, with a deficit. The more different the affinities, the greater the charge. Either a surplus or a deficit can make a spark.
One simple way to discharge a human buildup from walking across a rug with rubber-soled shoes, for example, is to touch a water pipe, faucet, or other grounding device just before touching the cat.
To prevent a strong shock to yourself, touch the keys from your pocket to the pipe. You will still feel something, but the sharpest part of the spark is at the point of the key. The discharge tends to occur at the minimum radius of curvature.
There are also antistatic sprays, some for preventing static cling in garments by insulating the fibers and some for use around computers that spread the charge around and allow the discharge of electrons to leak out over a wide area.