Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9025595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:18:39+00:00 2026-06-16T06:18:39+00:00

How can i erase character from a text string by pressing the back space

  • 0

How can i erase character from a text string by pressing the back space key.
This is what i have got so far. It only deletes the last character.

if (keyPressed) {
    if (key != '\n' && key != CODED) {
        if (typing.length() < 5){
            typing = typing + key;
        }
    }
    if (key == BACKSPACE) {
        if (typing.length() > 0) {
            typing = typing.substring(0, typing.length()-1);
        }
    }
}

text(typing, 345, 372);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:18:41+00:00Added an answer on June 16, 2026 at 6:18 am

    That’s because BACKSPACE is not CODED, so while typing.length() is smaller than 5and you press BACKSPACE you meet both conditions breaking stuff. When it reaches 5 it only mets second condition: if (key == BACKSPACE) so it works, bringing it back to less than 5 so it won’t work again…

    As a test try:if (key != '\n' && key != CODED && key != BACKSPACE)
    But i think you might want a switch (key) to do the job.

    Also you better use void keyPressed() or keyReleased() or keyTyped()
    Instead of keyPressed the field, in draw(). Or you will need to handle key repetition yourself…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got problem with erase function from string. I can't remove a single character
I have a QList variable. How can I erase all the elements starting from
How can I ensure that all data that I've erase from the db tables,
Is there anyway I can erase all the duplicate entries from a certain table
Possible Duplicate: How to filter items from a std::map? std::list::erase not working I have
I have data in R that can look like this: USDZAR Curncy R157 Govt
How can I modify the following so that it keeps the character '.'? This
In the console you can print \b to erase the character left of the
I have searched for this all over the web but can't seem to find
Is it possible to access the std::for_each iterator, so I can erase the current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.