For an application, I need to know the ASCII code for the enter key but I can't find it in the ASCII tables, could someone tell me what code it corresponds to?
"In computer science, CRLF, an acronym for Carriage Return (carriage return) Line Feed (line feed), is a special character or sequence of characters that indicates the end of a line of text. CRLF is sometimes referred to as carriage return, because before the existence of computers, typewriters physically returned the carriage."
# Wikipedia®
Thank you
nutz
totally worthless, the codes don't even match, it's 54 in batch evolve for a CR, and 32 for a LF.
honestly, well done to the false programmers
blux
Moderator
Hi,
what is 'batch evolve'???
Because in ASCII, 10 and 13 are indeed the indicated codes...
-- Cheers, Blux
"Idiots dare everything. That's even how we recognize them"
cchristian
Good evening,
Thank you three for these clarifications.
-- Best regards.
Christian.
henricson
The ASCII code for the Enter key on the keyboard is 13.
blux
Moderator
Read what was written earlier...
--
A+ Blux
"The idiots dare everything. That's how you recognize them."
Although this discussion is old, I'm going to ask a question:
Can you give me a way to programmatically retrieve the value 10 associated with the value 13 which, if I understand correctly, identifies the ENTER key? For my part, I only get the value 13 in my program using the _getch (or _getwch) function, even if I double the execution of this function as is the case for keys characterized by 2 values (Fx, DELETE, ...).
For me, there is a sequence of two because I don't know how to read them in C... Maybe access to the keyboard buffer?
--
A+ Blux
"Stupid people dare to do anything. That's how you recognize them"
fiddy
Contributor
@cchristianHi, It's more complicated than that regarding the enter key. At a very low level, the enter key corresponds to \r. But the OS performs the conversion (in non-raw mode) from '\r' to the newline character ('\r\n' for Windows, '\n' for Linux, '\r' for Mac OS). In C, if you use getchar(), you will get the conversion to '\n' regardless of the system (ensuring portability). If you use a low-level function like getch(), you will be in raw mode and will only get '\r'.
If you want to obtain '\r\n' to verify the conversion, the simplest way is to read a text file created on Windows; you will see that the newline character is '\r\n'.
If I may say so, the ASCII code for the Enter key is indeed 13, not 13 10. Code 13 means Carriage Return (CR) Code 10 means New Line (NL) The CR NL pair only appears in text files to indicate the end of the line. And still, it depends on the OS. For MS/DOS and Windows it's CR NL. On Unix, the end of line is NL. With Mac it's CR.
Most text editors automatically recognize these formats.
But as for the keyboard, the Enter key always has the ASCII code 13.
Cheers.
HarmonyService
it's ASCII code 13 that corresponds to Enter, usable in any C language: char x='\0'; c=getch(); if(c==13)printf("you just pressed the Enter key ");
P4T0U
The ASCII code you’re interested in should be 13!
P4T0U
...and 10! I just read the question well:P
fiddy
Contributor
If you read the question carefully, you must have noticed that it dates back 5 years now... What's more, we've covered it all since then.
Charbonnier
OD is the ASCII code for CR /r
fiddy
Contributor
And since OD equals 13 in decimal, we can find our way. Especially since the answer was given more than 4 years ago..
blux
Moderator
No, ASCII 13 corresponds only to the line feed, not to the carriage return as well... And to be very honest, it's been over 5 years since answers were provided...
fiddy
Contributor
HarmonyService, Avoid bringing up old posts, especially when you're not adding anything...
It's the ASCII code 13 that corresponds to Enter, usable in any C language: Yes, the enter key corresponds to '\r', which is 13 and allows finishing a line. But the OS converts it on the fly and transforms it to a line ending ('\n' on Unix, '\r\n' on Windows, etc.) But no, it's not usable in "any C language". By the way, that phrase doesn't mean anything. In C, the enter key corresponds to '\n' (10), which is usable regardless of the OS, that's what the standard says. The line ending is detected and converted to '\n'. If this is not the case with _getch(), it's because it's not a high-level function (raw mode), but non-standard.