A method comprising: determining a 3D position of an object relative to a surface based on 3D image data comprising pixels each having a location and depth value, the determining including: placing pixels in the 3D image data into a first group for background pixels, a second group for pixels in a contact zone relative to the surface, and a third group for pixels in a hover zone relative to the surface; detecting candidate groups of pixels in the 3D image that seem to be part of the same object based on their respective location and depth value; selecting a first of the candidate groups as being the input object; determining whether pixels in the selected group are in the contact zone; and determining whether pixels in the selected group are in the hover zone; rendering a transparent representation of a user input element over an image on a display associated with an electronic device based on the 3D position of the object relative to the surface; rendering the image below the transparent representation of the user input element on the display as distorted, wherein an amount of distortion of the image on the display is rendered based on a distance between the user input element and the surface to represent how far the user input element is from the surface, such that the amount of distortion is increased as the user input element is moved farther from the touch region and decreased as the user moves their user input element closer to the touch region; and receiving user input for the electronic device based on the 3D position of the object relative to the surface, including generating a touch event when pixels of the selected group are in the contact zone and generating a hover event when pixels of the selected group are in the hover zone, wherein the surface is not a surface of the display or of the electronic device. determining a 3D position of an object relative to a surface based on 3D image data comprising pixels each having a location and depth value, the determining including: placing pixels in the 3D image data into a first group for background pixels, a second group for pixels in a contact zone relative to the surface, and a third group for pixels in a hover zone relative to the surface; detecting candidate groups of pixels in the 3D image that seem to be part of the same object based on their respective location and depth value; selecting a first of the candidate groups as being the input object; determining whether pixels in the selected group are in the contact zone; and determining whether pixels in the selected group are in the hover zone; placing pixels in the 3D image data into a first group for background pixels, a second group for pixels in a contact zone relative to the surface, and a third group for pixels in a hover zone relative to the surface; detecting candidate groups of pixels in the 3D image that seem to be part of the same object based on their respective location and depth value; selecting a first of the candidate groups as being the input object; determining whether pixels in the selected group are in the contact zone; and determining whether pixels in the selected group are in the hover zone; rendering a transparent representation of a user input element over an image on a display associated with an electronic device based on the 3D position of the object relative to the surface; rendering the image below the transparent representation of the user input element on the display as distorted, wherein an amount of distortion of the image on the display is rendered based on a distance between the user input element and the surface to represent how far the user input element is from the surface, such that the amount of distortion is increased as the user input element is moved farther from the touch region and decreased as the user moves their user input element closer to the touch region; and receiving user input for the electronic device based on the 3D position of the object relative to the surface, including generating a touch event when pixels of the selected group are in the contact zone and generating a hover event when pixels of the selected group are in the hover zone, wherein the surface is not a surface of the display or of the electronic device.