I had the exact same problem with my Casio keyboard and a Yamaha sustain pedal I bought.
I'm not an electrical genius, but I was able to get it to work by opening it up and doing a little modification. Of course I first just tried switching the white wire with the black one but that didn't change anything at all when I tried it. It turns out the Casio wants the circuit completed to sustain, and broken for no sustain, which is the opposite of what the Yamaha pedal does.
I opened it up and mine had three three flat metal strips let's call them Top, Middle and Bottom. The Middle and Bottom ones were joined together on the right side, and the Middle and Top ones were touching on the left side when the pedal was not pressed. These seperated when the pedal was pressed, thereby breaking the circuit because the wires were on the top plate and on the joined Middle/Bottom plate.
So to flip it I:
1. Unsoldered the Bottom wire
2. Cut apart the Bottom and Middle plates on the right.
3. Bent the Middle plate on the right to touch the Top plate instead and soldered those together.
4. Soldered the Bottom wire back on.
That's it! Once I figured it out, it took only a few minutes to fix.
Usually answered in minutes!