Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Backspace Key
#1
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
Reply
#2
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...
Logic is the beginning of wisdom.
Reply
#3
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
Reply
#4
... But if you're planning on doing text input, the inkey function is the way to go - that's what ned/ngui uses.
Reply
#5
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
Reply
#6
Well... there two things that you can do that are far better than I can do... 1. Imagine; plan and create a game... and 2. Set yourself a deadline and stick to it... Super impressed!! You must tell me your secret... shhhh... I will hardly tell anyone... Moo Ha Ha Ha....
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)