I’ll give you a hint and an answer that might solve your problem.
All aligned to the right
90% of the calculators I know the alignment of the text is right. Do you know why? Because as the number grows you always know the last digit that was typed and can check the screen the last number that was entered.
So avoid changing the default behavior of already known objects. You can read about Affordance here https://brasil.uxdesign.cc/affordance-o-%C3%B3bvio-do-%C3%B3bvio-e91761f4403b
Affordance English term, not currently translated in Portuguese, but which, in this context, could be easily translated by "acknowledging" or "opportunity"
Source: https://pt.wikipedia.org/wiki/Affordance
So, even for the sake of Euristics, it would be interesting to keep the alignment right, which is the way most users are used to and which corresponds more faithfully to the calculators "real".
Euristicas de Nielsen
- Second Law: Correspondence between the system and the real world
- Fourth Law: Consistency and standards
Qui: http://blog.caelum.com.br/10-heuristicas-de-nielsen-uma-formula-pra-evitar-erros-basicos-de-usabilidade/
This is the Google calculator
This is the one from Windows
And that of Android
Now the code that can help you
Basically in your input
you should put a text-align: right
<input type="text" style="text-align:right" placeholder="digite aqui">
<br>
<br>
<input type="text" style="text-align:right" readonly value="texto a direita 0">
Without your code you can only answer on kick, post at least one Codepen or Jsfiddle so we can test
– hugocsl
You would have to concatenate the value you already have in the input + the number clicked. But it’s good to see your code because there are different ways to do this.
– Sam
@hugocsl I edited my post, that was my js code that I used to keep adding the typed numbers. (I’m a beginner, so I did it in the most basic way, I don’t know if there’s a better way).
– John Covv
John, I think it would be nice if you put the entire code, including CSS and HTML in addition to JS, because without CSS and HTML you can’t simulate your calculator. In last vc tb can post your code in a Codepen or Jsfiddle and post the link here.
– hugocsl
@hugocsl Upei no codepen, the link is at the end of the post, I accept any correction.
– John Covv
Face it seems that when the input text is larger than the input width it happens a by default one align the text to the left at Blur time, even though the input is initially aligned to the right... So when the input text exceeds its width and you click outside the field it does not align the text "correctly".... Look at this gif https://imgur.com/Qbi3l8D look at what happens after I fill and click out, it puts the text at the beginning....
– hugocsl
The alignment is only on the right if the input is focused. I’m searching how to fix this.
– John Covv
@hugocsl Ready, I was able to change using the "Direction" attribute of css, and added msm to ":not(:Focus)".
– John Covv
Very good John, nice balcony!
– hugocsl