Avoid bouncing on the edge when using the keyboard