Say if you have limited your frame rate at 60fps, that means the main loop will iterate 60 times per second.
Now if you press a key, the isKeyPressed will return true and you'll add a new shape every iterations.
That means, unless you manage to press the key for less than ~16ms, you'll always get more than one entry.
I personally, recommend to use events instead. And if you want to limit it to one key press & release cycle, then you'll need to track the key state.