no thats not the way to do it.
as you can see on the edit i made look at the IRremote.ino
and look at the void loop part. dont look at the digitalwrite relay stuff. imagine you code there.
but the irrecv.decode(&results) will be true i guess when you press a button.
then it debounces the presses with the millis stuff(millis() is better then delay() ). so it doesnt keep triggering.
then you can do your stuff.
reset the millis timer and ir stuff.
and wait for the next press.