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 123001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:13:03+00:00 2026-05-11T04:13:03+00:00

How does one go about attaching a bunch of code to an onkeydown event,

  • 0

How does one go about attaching a bunch of code to an onkeydown event, but keep entering text into a textarea fast and crisp? Anything more than a couple of IF statements seems to slow it down quite considerably.

EDIT: I should add (can’t believe I forgot!) that this doesn’t affect desktop browsers. It’s mainly an issue with iPhone Safari. Other mobile browsers might be affected as well, but we’re focusing on iPhone Safari since it executes JS the best (AFAIK)

  • 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. 2026-05-11T04:13:04+00:00Added an answer on May 11, 2026 at 4:13 am

    Considering your edit regarding this being focused on iPhone access…

    The iPhone really just doesn’t have that much power to it. You’ll be better off just using onchange or onblur instead of onkeydown.



    An alternative to Dave’s answer is waiting for the user to pause (e.g. for 5 seconds):

    var textarea = document.getElementById('textarea');  function checkTextArea() {    if (textarea.value /* ... */) {      /* ... */    } }  textarea.keyDownTimeout = null; textarea.onkeydown = function () {   if (textarea.keyDownTimeout) clearTimeout(textarea.keyDownTimeout);   textarea.keyDownTimeout = setTimeout(checkTextArea, 5000); }; 

    This should set the timer with the first keydown, stopping and recreating the timer for each successive keydown. Finally calling 5 seconds after the user stops typing.

    Also, note the lack of parenthesis after checkTextArea. This will give setTimeout the function’s reference vs. its return.


    You can also set this up in a function to make it easier to use for multiple elements:

    function setPauseTimer(element, timeout, callback) {   var timer = null;   element.onkeydown = function () {     if (timer) clearTimeout(timer);     timer = setTimeout(function(){ callback(element); }, timeout);   }; }  function checkTextArea(textarea) { /* moved from global to argument */    if (textarea.value /* ... */) {      /* ... */    } }  setPauseTimer(document.getElementById('textarea'), 5000, checkTextArea); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 117k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer class Program { static void Main(string[] args) { Timer timer… May 11, 2026 at 10:50 pm
  • Editorial Team
    Editorial Team added an answer Use GROUP_CONCAT SELECT GROUP_CONCAT(bar) FROM TABLE GROUP BY foo; May 11, 2026 at 10:50 pm
  • Editorial Team
    Editorial Team added an answer Your code doesn't work because the function is not returning… May 11, 2026 at 10:50 pm

Related Questions

Does anyone have some good information on the usage of the .SaveChanges() method? I
We have an internal Flex application which has been designed more through feature creep
How does one go about authoring a Regular Expression that matches against all strings
How does one go about referencing a class's static properties in xaml? In other

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.