An electronic device and a key input method using an external input device are provided. The electronic device includes a camera; a display; a communication interface; a memory; and a processor. The processor is configured to establish an electrical connection to an external keyboard; obtain an image of the external keyboard; set a key arrangement for the external keyboard based on the obtained image; and generate information corresponding to a key input signal received from the external keyboard based on the set key arrangement.