A wearable device is provided. The wearable device includes a communication circuit, a camera, a display, memory, including one or more storage media, storing instructions, and a processor communicatively coupled to the communication circuitry, the camera, the display, and the memory, wherein the instructions, when executed by the processor, cause the wearable device to transmit, to an external electronic device, information about a marker, display a
virtual keyboard through the display based on the marker, use information indicating the difference in brightness of each pixel included in an image, so as to detect, when the
virtual keyboard is displayed, the edge of a visual object indicating an external object, display an indicator, which is projected onto the
virtual keyboard and indicates the location of the external object, and execute an
input function, based on the virtual keyboard, based on receiving a
signal for a touch event through the communication circuit.