Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
how to keep track of letters in text overflow?

Hi Im working on a big project and the code is very complex to share parts of here. but i need to keep track of the letter that ii typing while the length of the name is bigger than the container. as you see in the video when text goes over the container it doesn't follow the letter that is being typed and you have to manually scroll. i need to follow the letters as i type it. note: the text box is not an input from html its a dive and the text is being typed by creating child divs in the text div that contain individual letters. the project is a mobile app built in cordova and it only works with a virtual keyboard no real physical keyboard functions here.

<div class="text-box">
<div>J</div>
<div>O</div>
<div>H</div>
<div>N</div>
</div>

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could add an event listener to the div which listens for key presses and then scrolls to the extreme right of the div (unless it is a backspace or delete key which is pressed) using the following code:

let display = document.getElementsByClassName('text-box');
let maxXscroll = display.scrollWidth - display.clientWidth;


display.addEventListener('keydown', function() {
    if((e.which != 8) && (e.which != 46)) {
        display.scrollLeft = maxXscroll;
    }
})

I apologise if my code is not good (it worked for me) or my answer is insufficient but I hope it helps you!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!