The invention relates to a user interface for controlling an electronic device. The user interface comprises a sensor element (201) that has a sensor surface (202) and is arranged to produce a location indicator that indicates a location of a spot (231) of the sensor surface that is closest to an external object (220). The user interface comprises force sensor equipment (203a, 203b) that is arranged to produce a force indicator that indicates temporal changes of force components directed to the sensor surface in parallel with the sensor surface. A processor unit (205) is arranged to control the electronic device on the basis of the location indicator and the force indicator. A user of the electronic device is enabled to control the electronic device by using different levels and directions of force and/or torque directed to the sensor surface.