Resizing an Object with Keystrokes

My first post so please be gentle. I recently came across Blender and have been attempting to navigate through some of the features by watching the plethora of video tutorials available all over the Net. I am, like many of you, very interested in the Game Engine and Scripting. So far, I have been able to get things to move using the keystrokes and Logic Bricks as well as including some scripting to do these same actions. I have a considerable amount of experience with Visual Basic for Applications but zero with Python… and I have already discovered that there are really no similarities with these two languages.

My initial project is to create scripting that causes an object to ‘pulse’. More precisely, when a certain keystroke (RIGHTARROWKEY) has been, I want the object to smoothly scale up in size (by a factor of 2), hold that size for approximately 0.25 seconds, and then smoothly go back to its original size. This action is to be repeated only when that keystroke is made again.

I am able to make the object increase in size but cannot get it to reduce back to the original size plus my attempts to use any sort of timer caused Blender to freeze. I have searched the forums for similar questions but could not find any answers. There are probably much better methods to do this; however, I only have two week’s worth of Blender experimentation behind me so I simply do not know of another approach. I am using Blender v2.67b. Any help will be greatly appreciated. Below is my code:
Daryl G

import bge
def main():

if[] and cubeobject.localScale.x<2:
while i<10:
print(i, cubeobject.localScale.x)

    #while i&gt;0:
    #    cubeobject.localScale.x-=0.05
    #    cubeobject.localScale.y-=0.05
    #    cubeobject.localScale.z-=0.05
    #    i=i-1
    #    print(i)