diff --git a/keyboard.xml b/keyboard.xml
index 621df85fd..e87cf4cff 100644
--- a/keyboard.xml
+++ b/keyboard.xml
@@ -570,8 +570,8 @@ calculated by adding 256 to the GLUT key value in glut.h.
nasal
@@ -755,7 +755,7 @@ calculated by adding 256 to the GLUT key value in glut.h.
return setprop("/sim/hud/visibility", 1);
}
var i = getprop("/sim/hud/current-color") + 1;
- if (i >= size(props.globals.getNode("/sim/hud/colors", 1).getChildren("color"))) {
+ if (i < 0 or i >= size(props.globals.getNode("/sim/hud/palette", 1).getChildren("color"))) {
setprop("/sim/hud/visibility", 0);
setprop("/sim/hud/current-color", 0);
} else {