Key Press help needed!

I’m doing an interactive TV project for college and the site needs to be navigated via the “r” “g” “y” “b” keys.

I’m not entirely sure how to do this. Basically what i did do was add a script layer and the code :

on (keyPress "r") {
	gotoAndPlay(30);
}
on (keyPress "g") {
	gotoAndPlay(20);
}
on (keyPress "y") {
	gotoAndPlay(10);
}
on (keyPress "b") {
	gotoAndPlay(1);
}

However, it tells me i can’t use the on command there because it’s not a movie clip. Is there anyway i can do what i want to do a different way?

Thanks for you help.