An electronic device comprising: a display; a sensor module including a touch sensor configured to receive a touch input and generate touch data; memory; and at least one processor operatively connected to the display, the sensor module, and the memory, characterized in that the memory stores instructions that, when executed by the at least one processor individually or collectively, cause the electronic device to: generate a first filter having a first time filter value and a first magnitude filter value, generate a second filter having a second time filter value greater than the first time filter value and a second magnitude filter value greater than the first magnitude filter value, acquire the touch data including a first point where a touch starts and a second point where the touch ends, apply the first filter based on a moving from the first point to the second point being closer to a center line that vertically bisects a keyboard, apply the second filter based on the moving being farther away from the center line, determine that a key of the keyboard corresponding to the first point has been touched based on a duration of the touch input being less than the time filter value of the filter and a distance between the first point and the second point being less than the magnitude filter value, and determine that a key of the keyboard corresponding to the second point has been touched based on the duration of the touch input being equal to or greater than the time filter value of the filter and the distance between the first point and the second point being equal to or greater than the magnitude filter value. a display; a sensor module including a touch sensor configured to receive a touch input and generate touch data; memory; and at least one processor operatively connected to the display, the sensor module, and the memory, characterized in that the memory stores instructions that, when executed by the at least one processor individually or collectively, cause the electronic device to: generate a first filter having a first time filter value and a first magnitude filter value, generate a second filter having a second time filter value greater than the first time filter value and a second magnitude filter value greater than the first magnitude filter value, acquire the touch data including a first point where a touch starts and a second point where the touch ends, apply the first filter based on a moving from the first point to the second point being closer to a center line that vertically bisects a keyboard, apply the second filter based on the moving being farther away from the center line, determine that a key of the keyboard corresponding to the first point has been touched based on a duration of the touch input being less than the time filter value of the filter and a distance between the first point and the second point being less than the magnitude filter value, and determine that a key of the keyboard corresponding to the second point has been touched based on the duration of the touch input being equal to or greater than the time filter value of the filter and the distance between the first point and the second point being equal to or greater than the magnitude filter value. generate a first filter having a first time filter value and a first magnitude filter value, generate a second filter having a second time filter value greater than the first time filter value and a second magnitude filter value greater than the first magnitude filter value, acquire the touch data including a first point where a touch starts and a second point where the touch ends, apply the first filter based on a moving from the first point to the second point being closer to a center line that vertically bisects a keyboard, apply the second filter based on the moving being farther away from the center line, determine that a key of the keyboard corresponding to the first point has been touched based on a duration of the touch input being less than the time filter value of the filter and a distance between the first point and the second point being less than the magnitude filter value, and determine that a key of the keyboard corresponding to the second point has been touched based on the duration of the touch input being equal to or greater than the time filter value of the filter and the distance between the first point and the second point being equal to or greater than the magnitude filter value.