Click the FLAGGGGGG!!! UPDATE 1/21/16: Now can press arrow keys and Z and X to rotate! Seems normal, right? 3 angles of rotation for the cube. But try to slide yP(pitch) to 90. Now try to spin zY and xR. Notice how the yaw(zY) and the roll(xR) gimbals line up, costing one degree of freedom. This is an example of gimbal lock. You can see it approaching gimbal lock as yP is close to 90, like 89, as the yaw and roll rotations become closer and closer together. Also notice how all gimbals rotate with the blue gimbal (roll), but when the green gimbal(yaw) turns, the blue gimbal is unaffected. This is because of parenting. First is roll, then pitch, then yaw. Roll is the main control, pitch is middle, and yaw is fully dependent of pitch and roll. You can see this from the gimbals.
Credit to @raucket for introduction to 3D and The Guerrilla CG Project for explanation of gimbal lock. Just found out that my 3D engine uses Euler angles. Quaternions don't have this problem, which is why I am trying to learn them. One solution of this problem is to add a second layer of yaw, pitch, and roll, but this requires even MORE numbers and memory, as these Euler angles use sin() and cos(), which are very hard to compute, compared to addition and multiplication. An example of this is at https://scratch.mit.edu/projects/73357106/