I used getAnchor on the dragon object to get its center point, and then getx and gety on that. Then, when I check for the keypress, I also used the x and y I found to see if the dragon is at the edge of the window, and keep the dragon from moving if its too close.