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

  • SEARCH
  • Home
  • 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 8235489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:49:43+00:00 2026-06-07T18:49:43+00:00

First of all, Console.ReadKey() is not the answer. I need to be able to

  • 0

First of all, Console.ReadKey() is not the answer.

I need to be able to erase the first character I write.

Basically, what I’m trying to do is an application that measures your typing speed.
It works perfectly, but I’m trying to work out the aesthetics.

What I was doing at first was calling Console.ReadKey(), then calling this function that starts a Timer (well, I realized 30 minutes after I wrote the application that there happens to be a Stopwatch class ._.), and I would store the string that the user inputs with Console.ReadLine(), then stop this Timer.

static Word[] getWords()
{
    Word[] words;
    int c = Console.ReadKey().KeyChar;
    Timing.start();
    string str = (c.ToString() + Console.ReadLine()).ToLower();
    charCount = str.Length;
    words = Word.process(str);
    Timing.stop();
    return words;
}

charCount is a static int, and Word is just a class that wraps a string.
Word.process is a function that takes a string, omits all the symbols and returns an array of the words that the user types.
Timing is just a class that wraps the Timer class.
I think that’s all that needs to be explained concerning the code.

What I need to do is call Timing.start() when the user types a character and he has to be able to erase it.

  • 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-07T18:49:44+00:00Added an answer on June 7, 2026 at 6:49 pm

    Needs a bit of tweaking, but how about something like this?

    Update – now one (1) backspace works, but multiple doesn’t. argh! Hopefully this will point you in the right direction though.

    Update #2 – using StringBuilder…. backspaces work now 🙂

    namespace ConsoleApplication4
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                StringBuilder sb = new StringBuilder();
                // you have alot of control on cursor position using
                // Console.SetCursorPosition(0, Console.CursorTop -1);
                List<DateTime> inputs = new List<DateTime>();
                ConsoleKeyInfo cki;
    
                Console.WriteLine("Start Typing...");
                Console.WriteLine("Press the Escape (Esc) key to quit: \n");
                do
                {
                    cki = Console.ReadKey();
                    if (cki.Key == ConsoleKey.Spacebar)
                    {
                        sb.Append(cki.KeyChar);
                    }
    
                    else if (cki.Key == ConsoleKey.Backspace)
                    {
                        Console.Write(" ");
                        Console.Write("\b");
                        sb.Remove(sb.Length - 1, 1);
                    }
    
                    else if (cki.Key == ConsoleKey.Enter)
                    {
                        sb.Append(cki.KeyChar + " ");
                        Console.WriteLine("");
                    }
    
                    else
                    {
                        sb.Append(cki.KeyChar);
                    }
    
                    inputs.Add(DateTime.Now);
                } while (cki.Key != ConsoleKey.Escape);
    
                Console.WriteLine("");
                Console.WriteLine("=====================");
                Console.WriteLine("Word count: " + Regex.Matches(sb.ToString(), @"[A-Za-z0-9]+").Count);
    
                TimeSpan duration = inputs[inputs.Count - 1] - inputs[0];
    
                Console.WriteLine("Duration (secs): " + duration.Seconds);
                Console.ReadLine();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, let me say that I am not a professional coder -
Okay first to explain the rules: I need a function that constructs a delegate
First of all, until now, all my programming education, has been targeted to console
First of all, I must state that I'm a complete newb when it comes
First of all I want to point out that I could translate the error
First of all, please excuse any typo as English is not my native language.
First of all I'm not entirely sure what I'm doing or expecting is right.
I'm trying to remove all my console.log , console.dir etc. from my JS file
i want to launch ffmpeg from my app and retrive all console output that
First of all, this will not be a post about Database Transactions. I want

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.