Python Forum
Python - Most effective way to correct keyboard-user-input.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python - Most effective way to correct keyboard-user-input.
#1
Hello everyone,
I am working on a project, which corrects user input (reads input stream from keyboard with keyboard module) based on some rules.
I am trying to find the fastest way to delete and write the corrected word, after a user enters a wrong one.
Currently I am using pynput, but I noticed that it faces problem when the user types very fast.
To give you a better idea of what I am looking for, I quote the above pseudocode.

user enters a word
some_checks_are_made
if (ok):
do nothing
else:
press_the_backspace_button_until_delete_of_wrong_entered_word
write_the_new_word

To make it even more clear, the main problem I am facing is that my program delays on deleting and writing the correct word and the user overlays the words written from the program.
e.g. (just an example - not program's functionality)

user writes 'honeu' (the correct word is honey)
program starts deleting and deletes until 'ho___'
user starts typing next word 'hello'
the result is 'hohelloney'
I tried explaining it as better as I could.

I am just asking for any suggestion or solution to this problem.
! Some suggestion was, to grab the word as it's being typed, calculate your correction, then go back to the text and make the correction all at once if the word is still there. This means storing the text in a buffer (not repeatedly simulating backspace presses).
But I don't know how to go back to the exact position that the word was written.
Thanks in advance.
Reply


Messages In This Thread
Python - Most effective way to correct keyboard-user-input. - by ppel123 - Apr-06-2020, 08:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  WHILE LOOP NOT RETURNING USER INPUT AFTER ZerroDivisionError! HELP! ayodele_martins1 7 991 Oct-01-2023, 07:36 PM
Last Post: ayodele_martins1
  restrict user input to numerical values MCL169 2 869 Apr-08-2023, 05:40 PM
Last Post: MCL169
  user input values into list of lists tauros73 3 1,025 Dec-29-2022, 05:54 PM
Last Post: deanhystad
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,033 Dec-25-2022, 03:00 PM
Last Post: askfriends
Question Take user input and split files using 7z in python askfriends 2 1,031 Dec-11-2022, 07:39 PM
Last Post: snippsat
Sad how to validate user input from database johnconar 3 1,837 Sep-11-2022, 12:36 PM
Last Post: ndc85430
  Help Switching between keyboard/Mic input in my code Extra 1 1,046 Aug-28-2022, 10:16 PM
Last Post: deanhystad
  How to split the input taken from user into a single character? mHosseinDS86 3 1,138 Aug-17-2022, 12:43 PM
Last Post: Pedroski55
  Use pexpect to send user input alisha17 0 1,829 May-10-2022, 02:44 AM
Last Post: alisha17
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,434 Apr-05-2022, 06:18 AM
Last Post: C0D3R

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020