Object control

am creating a object using key board controls.using key the object will go out of the screen with endless how i use the key controls within the screen only. anybody help