arturfromelbląg
What you describe is a fairly common problem (and solution) for Apple's USB keyboard. But I've usually seen that problem/solution when the keyboard is connected with an external display - not when simply directly connected to a USB port on the MacBook Pro.
Is the USB port working fine with other devices? If so, were I you, I would make a trip to your local Apple Store and see if they will exchange the keyboard for you. Having a receipt would be good. If the keyboard is less than a year from date of purchase, that would be good as well.
I had the same problem with my machine when the keyboard was plugged into my Apple Thunderbolt Display's USB hub. Put the extension in the chain and everything worked.
Good luck,
Clinton
MacBook Pro (15” Late 2011), OS X 10.??, 16GB Crucial RAM, 960GB M500 Crucial SSD, 27” Apple Thunderbolt Display