 Hello! Today I'm going to be answering a question I received. Well, kind of answering it. The question starts off like this. Starts off with a comment. A nice comment. Hello, Chris. I really like your videos. Thank you. I was wondering if you could help me. I want to read a character from my keyboard for an arm machine without pressing the Enter key. Great. I know how to do that. So, if I was to type W, the program writes up. If A, it is, writes left. If it's D, it writes right. If it's S, it writes down to a text file without the need to press Enter. Great. I answered. I sent him a script. And then I went back and realized the last line of his question is, I want to do this in arm assembly. Now, I know very, very, very little assembly. A couple of years ago, I went through a tutorial and I learned how to make a bootloader for an x86 machine. And I modified that a little bit to have different colors and where you could press keys on the keyboard to display those keys. And that's about as far as I got on that. The only other assembly I've really done was just the other day. I was taking, reading a tutorial on writing your own Nintendo ROMs in assembly. And as far as I got, that was just displaying different colors on the screen. And that's it. So, I don't know how to do that in arm assembly. Although, if I have time today, I might look into that. But doing it with a shell script or a bash script, which will run on an arm machine, I can show you. So, that's what I'm going to go over today, David. So, it's not exactly what you asked, but hopefully it will help some. And I'll look into your question a little bit more if I have the time. But for the rest of you, let's have a look at this. Let's jump into the computer here. Okay, I'm in an empty directory. Let me make a script. I'll just call it keys. Whoops, keys.sh. I will make that executable. And then I will edit it. Whoops, not twice. There we go. Okay, let's go ahead. And it's going to be a bash script. And so, what are we going to do? We're going to use the read command to get a key input. So, let's exit back out to our shell here real quick. I'm in bash. I can do read. And then I can give it a variable like x. And it's going to wait for me to press type something. So, I can type something. And that puts that into the variable x. So, now, I can, my key fingers around the wrong keys, echo dollar sign x and it will echo out what I entered. Now, of course, I can do that. And I can type in one key and then hit enter. And that has now changed the variable x to l. But I don't want to have to press enter. So, the option and remember the read command is built into your shell and different shells may act differently. Again, we're doing bash here. I can do dash n and give it a number like one. This is saying it's looking for a one character response. So, now, I run that command and I can hit a key like p. And now, I didn't have to hit enter. I can echo out x and it's p. Now, you'll notice that when I typed p, it showed up on the screen. We don't necessarily want that. So, what we can do is we can add the s, which is for secret. At least, I think that's what it stands for. It's more for when you're using the read command for passwords. So, they don't display on the screen. But here, we're just going to do it. So, it doesn't display what key you're pressing, but still saves it to the variable x. So, I can press that. Now, I can press any key on the keyboard. Well, not any keys. I don't think shift will do anything. But I'll hit y. And now, I can echo dollar sign x and you can see it equals to y. So, hopefully, see we're going with this. So, now, we can put that into a while loop. And depending on what key is pressed, we'll just echo something out the screen, but you can run a function of some sort. So, let's go back into our script here. And we're going to make a loop that goes on forever and ever. Not then. We're going to go do done. So, this will loop forever. And we're going to say read. And we're going to do just like we did dash s and one for one character. And I'll just say k for keys. It will be our variable. But you can name it keys if you want. I'm just going to keep it short k. Now, we're going to write if then statement. So, we can do the whole long hand if then whatever. But it's just simpler to do it shorthand. So, we're going to say dash, not dash. Inside double brackets, we're going to say check key does key equal w. And then we're going to say ampersand, ampersand. If that's true, run this next command. We'll just echo up, right? And let's just copy this three more times. And we will change this from w to s, a and d. And here we'll go down, left, right. And that is our whole script, at least for this example. So, we have that. And again, so it's going to loop forever. It's going to wait for you to type something. It's going to continue. If it's one of these characters, it's going to echo one of these. If not, it's just going to loop again. And of course, you can put a key in there for exiting out of that. You could break out a loop with x or q or something. But let's go ahead and save that. Let's go ahead and just run it. And nothing displays on the screen because we didn't put a prompt. With read, you could put a prompt. But here, if I can start hitting like k or l or m, nothing happens. But I'll hit w. It says up, s, down, a, left, d, right. So again, I can press those keys. But other keys, it's grabbing those, checking those. But since they aren't in any of our if statements, it just loops back around. So that's it. I will put a link to this example script in the description of this video. It's up on Payspin. I hope that you got something out of this, even though it's not exactly what the person asked. It does do what they asked, just not in the language they asked for. But you might find this useful. You can draw stuff to the screen or just have different outputs with single key presses. Now, you might ask, those are letter characters. What if you wanted to use the arrow keys? And the answer to that is, I don't know. I haven't looked that up yet. So we're using WASD for up, down, left, right. But if I was to do arrow keys, that's not doing anything. I'm sure there's a way to check that, but I haven't looked into that yet. But I know someone might ask that in the comments below. So before you ask, I have answered. If you do have a question, a comment, comment below. But you can see that I do answer people's questions, but I have a lot of videos out there. And I don't check the comments on all of them. Usually I check the comments on my most recent video. So if you have a question, go ahead and comment below. But if you look at the date on this video, and it's months or weeks or years from now, go to my website, filmsbychrist.com, that's Chris of the K, and check out what my most recent video is. You'll see it in the list of videos there. Or just go to my channel here on YouTube. And if you're going to ask a question, I think the best way for you to get me that question is to ask it on my most recent video. So go to my most recent video and comment there. Or if you really want to get guaranteed that you're going to get an answer, you can always become a patron. If you're a patron of mine on Patreon, patreon.com forward slash metal X 1000. There's a link to that in the description as well. I try to always respond to my patrons. And there's a few patrons that I talk to regularly. In fact, one of my patrons has a chat room set up for me on one of his servers that I set up just for my patrons. So you can ask me a question through the Patreon website, but their little chat interface is horrible. Sometimes it doesn't notify me that you've you've sent me a response. So contact me on Patreon if you're a patron of mine, and I can get you access to this other server where I'm daily checking questions and comments. So yeah, those are the ways you can contact me. If you want to support Patreon, there's also a support section on my website where you can support me through Patreon, LibrePay or PayPal. But I also just thank you for watching, sharing, subscribing and commenting. I hope that you have a great day.