Python Forum
Problem with input after function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with input after function
#7
(Nov-29-2021, 04:30 PM)deanhystad Wrote: Next time you post you should post a working example. At least that would show the imports. You should have mentioned that you are using a keyboard package. Maybe this one?

https://pypi.org/project/keyboard/

It seems obvious to me that making enter a hot key is going to break input() which uses enter to signal the end of typing. If you want to use this package you might need to make your own input-like function. The pressed_keys.py example looks like a good start for something like this.

https://github.com/boppreh/keyboard/blob...ed_keys.py

Hello deanhystad, i'm trying to find a solution, but also with hook function,
the problem is always the same.

import keyboard

def presentation():
        input("Name: ")
        input("Surname: ")

def my_keyboard_hook(keyboard_event):
    if keyboard_event.name == "enter":
        print("You have pressed the key: " + keyboard_event.name)
        presentation()

    elif keyboard_event.name == "space":
        print("You have pressed the key: " + keyboard_event.name)

keyboard.on_press(my_keyboard_hook)
keyboard.wait()
Could you check this code and kindly tell me what i'm wrong !? please ...
Reply


Messages In This Thread
Problem with input after function - by luilong - Nov-27-2021, 08:14 PM
RE: Problem with input after function - by luilong - Nov-28-2021, 12:19 AM
RE: Problem with input after function - by ghoul - Nov-28-2021, 10:52 AM
RE: Problem with input after function - by luilong - Nov-28-2021, 11:13 PM
RE: Problem with input after function - by luilong - Nov-29-2021, 08:53 PM
RE: Problem with input after function - by luilong - Nov-29-2021, 10:55 PM
RE: Problem with input after function - by luilong - Dec-04-2021, 12:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 1,246 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  problem in using input command akbarza 4 1,390 Oct-19-2023, 03:27 PM
Last Post: popejose
  problem in entering address of a file in input akbarza 0 732 Oct-18-2023, 08:16 AM
Last Post: akbarza
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,216 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Showing an empty chart, then input data via function kgall89 0 1,036 Jun-02-2022, 01:53 AM
Last Post: kgall89
  input function question barryjo 12 2,970 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 3,336 Jan-15-2022, 06:07 PM
Last Post: deanhystad
  Exit function from nested function based on user input Turtle 5 3,078 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 2,055 Oct-06-2021, 09:39 AM
Last Post: menator01
  Input function cutting off commands at spaces. throwaway34 3 2,299 May-12-2021, 06:40 AM
Last Post: throwaway34

Forum Jump:

User Panel Messages

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