Web page typing and focus control

Also fixed losing focus of elements with keyboard focus so it only
occurs if the clicked element is at the bottom of the element tree and
so it properly clears the focus control field.