[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Delete key issue...
"Harry Potter" <rose.joseph12@yahoo.com> wrote:
> the backspace key acts as a left cursor key. Any idea on why? And how to
> fix it?
/* keypress values for the apple */
#define RTARROW 21
#define LTARROW 8
#define UPARROW 11
#define DNARROW 10
#define ESCAPE 27
#define DELETE 127
#define ENTERKEY 13
#define SPACEBAR 32
The ascii value for the backspace key whether one writes code for the Apple
II or MS-DOS is 8.
The fix is to forget about writing code for the Apple II and focus your
efforts on code for some other platform:
/* arrow keypress values for the commodore 64 */
#define UP_ARROW 145
#define DOWN_ARROW 17
#define LEFT_ARROW 157
#define RIGHT_ARROW 29
MS-DOS arrow keys might be a little trickier for you in a C program... so
staying away from C altogether and writing in QuickBASIC for MS-DOS might be
a better alternative:
'constants for keypress values
NUL$ = CHR$(0)
UP$ = NUL$ + CHR$(72)
DN$ = NUL$ + CHR$(80)
LT$ = NUL$ + CHR$(75)
RT$ = NUL$ + CHR$(77)
ESC$ = CHR$(27)
ENTER$ = CHR$(13)
FLAG = 0
WHILE FLAG = 0
KEYPRESS$ = INKEY$
SELECT CASE KEYPRESS$
CASE UP$ 'uparrow
CASE DN$ 'down arrow
CASE LT$ 'left arrow
CASE RT$ 'right arrow
CASE ESC$
FLAG = 1
CASE ENTER$
FLAG=1
END SELECT
I think arrow keys in a message loop in a Windows C Program would be very
hard for you to manage so I have refrained from posting an example.
> I am willing to post the code online--
No need to go to all that work... but thanks for the offer.
Here's some code (bottom of page) that may help you understand a little
better... it's in Aztec C65 but any C programmer (and I mean ANY C
programmer) would have no trouble porting this code to another Apple II C
compiler... clue - consider using cc65's functions to replace mine (this
might work for you, who knows):
while (kbhit() == 0);
c = cgetc();
You may use this code for whatever you wish as long as you agree that Bill
Buckels has no warranty or liability obligations whatsoever from said use.
/* return ascii values for apple key presses */
#include <stdio.h>
int getch()
{
char *KEYPRESS = (char*)0xC000;
char *KEYCLEAR = (char*)0xC010;
char c;
/* clear stragglers from the keyboard buffer */
while((c=KEYPRESS[0]) > 127)KEYCLEAR[0]=0;
/* read the keyboard buffer */
/* and return the character */
do{
c = KEYPRESS[0];
}while(c < 128);
c-=128;
KEYCLEAR[0]=0;
return (int )c;
}
main()
{
int c=0;
scr_clear();
while(c!=27)
{
printf("Press a Key : \n");
c=getch();
printf("Key = \"%c\". Ascii = %d.\n",(char)c,c);
}
scr_clear();
_exit(0);
}
- Bill