Skip to main content

Pygame Text Input

A small module that enables you to input text with your keyboard using pygame


Silas Gyger
(nearoo)
Write text in pygame! This small module can be used to write text in pygame. It includes a blinking cursor that can be moved using the left and right arrow key as well as the home and the end button. You can adjust text color, font, antialias, and more. Install with `pip install pygame-textinput`, and check github for instructions!

Changes

Links

Home Page
https://github.com/Nearoo/pygame-text-input

Releases

Pygame.org account Comments

  • William Savage 2017-01-05 16:23

    Amazing module! Thank you very much, ive been using Eztext for my project and it hasnt been working very well. When i add your cxode from github and add the:
    if textinput.update(events):
    print(textinput.get_text())

    I get every key i pressed comes up twice, is their a way round this as it kind of ruins the module

    William Savage 2017-01-05 23:12

    I have solved this

    Matt 2017-01-08 02:36

    Could you possibly post how you solved it, in case anyone else comes here with the same problem?

    skrell 2017-03-23 13:34

    I guess you forgot that evaluating "if textinput.update(events):" actually calls the function that implements your string. If you put textinput.update(events) elsewhere in your code it just does it twice.
  • William Savage 2017-01-05 16:27

    Also is there anywhere to have a pre-displayed text that user changes? Thanls

    William Savage 2017-01-05 16:35

    Apologies for the several requests but is there also a way to inhibit the max le;bth of the string like you can in EzText

  • Henry D 2017-03-20 19:45

    Hey! does this allow for a text box to be blitted to the game display? i intend to use this as a user friendly input for a quiz, (non for profit of course) and was wondering if the text box can be blitted to a certain part of the screen(in my case the bottom middle of the game display) thanks in advance :)

    Nearoo 2018-07-03 19:17

    Yes! You have total control over where and on what the surface is blitted. Check out github for more infos: https://github.com/NSasquatch/pygame-text-input
  • Anton de Groot 2017-11-22 20:22

    Awesome module, it has been very helpful. One thing I've noticed though is: When I type "^" it gets stuck in a loop and keeps entering ^'s. It does this whenever ^ is entered by "shift+6+space". However this does not occur when ^ is entered by the combination: "shift+6". On Ubuntu I have two keyboard settings: "(us,with dead keys)" and just "(us)". The bug occurs on "us,with dead keys" but not the other. This means that on windows this might occur on Dutch/Norwegian/... keyboards but not on an English keyboard or keyboard setting.
  • Rodion 2019-02-09 09:21

    I get an error: import pygame_textinput ModuleNotFoundError: No module named 'pygame_textinput'
  • LolloAntoni 2019-08-26 17:25

    How do you install it?
  • S 2020-06-15 08:07

    How do you install it?