We'll also expand our keydown handler to
detect the "H" and "V" keys (codes 72 and 86 respectively).
When these keys are detected, we'll reverse the corresponding 'flip' variable.
function MyKeyDownHandler (MyEvent) {
if (MyEvent.keyCode == 72) (thing.flipH = !thing.flipH); // H
if (MyEvent.keyCode == 86) (thing.flipV = !thing.flipV); // V
if (MyEvent.keyCode == 37) {thing.angle = thing.angle - 15}; // left
if (MyEvent.keyCode == 39) {thing.angle = thing.angle + 15}; // right
MyEvent.preventDefault();
}
(Recall the exclamation mark, "!" is a logical not operator, just like the "not" block in Scratch. The effect of these two lines of code is to say, "if it wasn't flipped, flip it; if it was flipped, unflip it">