Made a slight optimization to the keyboard API.