NaaLaa
Backspace Key - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html)
+--- Thread: Backspace Key (/thread-227.html)



Backspace Key - 1micha.elok - 04-23-2025

Hi
I am working with some keydown event codes, but I can't seem to find the key code for the backspace key. 
Could you kindly advise me? Thank you!

Code:
#win32
set window "KEYDOWN",200,100,false,4
set redraw off

while not keydown(KEY_ESCAPE)
    set color 0,0,0
    cls
   
    set color 255,255,255
    set caret 10,10
    if keydown(KEY_INSERT) wln "Insert"
    if keydown(KEY_DELETE) wln "Delete"
    if keydown(KEY_HOME) wln "Home"
    if keydown(KEY_END, true) wln "End"
    if keydown(KEY_PAGE_UP) wln "Page Up"
    if keydown(KEY_PAGE_DOWN) wln "Page Down"
    'if keydown(KEY_BACKSPACE) wln "Backspace"
   
    redraw
    fwait 10
wend



RE: Backspace Key - johnno56 - 04-23-2025

To tell you the truth, I have never needed to code a program that required backspace...

As a work-a-round... The ASCII value for backspace is 8. I suppose you could probably use:
if inkey() = 8 then wln "Backspace"
The "timing" of the key press and or release may not be the same as keydown but it should work... kind of...


RE: Backspace Key - Marcus - 04-23-2025

I've just not defined a named constant for it. You can use 8, as johnno suggested, with the regular keydown function:

Code:
if keydown(8)
  ...
endif



RE: Backspace Key - Marcus - 04-24-2025

... But if you're planning on doing text input, the inkey function is the way to go - that's what ned/ngui uses.


RE: Backspace Key - 1micha.elok - 04-25-2025

Thanks, Johnno and Marcus, for the tips on handling the backspace key in Naalaa—whether it’s using `keydown(8)` or checking if `inkey() = 8`. I’m working on a text-based game, kind of like a fantasy computer or a typing tutor, where I need to catch the backspace key. The game’s not done yet, but I’m hoping to drop an alpha version in the next couple of weeks.

Big Grin