How do i detect a keypress such as Page-Down ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How do i detect a keypress such as Page-Down ?
# 1  
Old 05-15-2010
How do i detect a keypress such as Page-Down ?

Hi,

New user here, I have googled this but found nothing that helps me.

I have a file of data and want to display it to a user from within a "frame/window/screen" that allows the user to pageup/pagedown through the data.

I can do this mostly, but I cannot detect the pressing of the pageup/pagedown keys.

I can get it to go with say "u[Enter]" for up using read input, but I want it to be one keypress of the pageup key.

Can anyone point me at some info on how to do this ?

Using HP-UX, with KSH-88.

Cheers
Greg

---------- Post updated at 12:57 PM ---------- Previous update was at 12:26 PM ----------

stty -a shows that -icanon is set, so I should be able to catch the key press ????
# 2  
Old 05-15-2010
I don't quit understand what you are writing this in.
In C use should use the curses library to interpret function keys,
In ksh, why not just use the "less" command.
# 3  
Old 05-15-2010
# 4  
Old 05-15-2010
There is no "less" in this ksh.

Why not use "pg", "page" or "more" ? All allow page up/down though it is not through the named keys on the keyboard.

Of these programs "pg -r" stops shell breakout and you can get "pg" to output instructions to the user.
# 5  
Old 05-16-2010
@Franklin52 - This example was for bash and I am using ksh, and a newbie to boot, so i couldn't get it to fly.

@jgt - I may have to explore the C option, I had wanted to just use ksh if possible.

@methyl - I had wanted to display a type of header (2-3 lines) at the top of the screen and then have a page at a time displayed underneath it. So the pg option will not preserve that. But it may be the quickest workaround to do. I'll try that for now and see if I can improve on it later.

Thanks all for the responses ...
GC
# 6  
Old 05-16-2010
You might try this, xHarbour.org , assuming that it will compile and run on HP-UX.
Here is the source code for your request.
Code:
create temp                        
append blank                       
replace field_name with "text"     
replace field_type with "C"        
replace field_len with 75          
replace field_dec with 0           
close temp                         
create text from temp              
append from t.prg sdf              
go top                             
heading1="For our first report"    
heading2="Name Addresss Invoice No"
@1,40-len(heading1)/2 say heading1 
@2,40-len(heading2)/2 say Heading2 
browse( 3,5,14,70)                 
quit

# 7  
Old 05-17-2010
Thanks for the help jgt, but management policy precludes adding other 3rd party stuff to the box. An interesting read none the less.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simulate keypress in bash

Hello everybody, I am using Windows 10 and cygwin/bash. I need to write a script in bash which simulates opening of a program and then press some keys such as F5, ENTER and ALT+F4. I have written a VBScript which does the job Set WshShell = WScript.CreateObject("WScript.Shell")... (9 Replies)
Discussion started by: supernono06
9 Replies

2. Shell Programming and Scripting

Bash loop hording keypress input

I have a bash loop that waits for a single key press, then does $something depending on what $key is pressed before refreshing the screen with updated data. The problem I have is that the script will store additional key presses and chain them together causing the screen to redraw and the script... (1 Reply)
Discussion started by: DarkPhoenix
1 Replies

3. Programming

Simulate keypress inside a non-x application...

Hey guys, I'm looking for a solution to simulate a key-combo (tab+q) inside an amiga-emulator. I've tried it with uinput and python without any success. Any help would be great. Cheers McCarthy (5 Replies)
Discussion started by: mccarthy83
5 Replies

4. Shell Programming and Scripting

Trying to Bind a keypress to a function

I've been trying to re-think an old problem that didn't get answered. I know this is possible, but I'm having trouble getting it to run. I just want to call a function with a key-press or key combination. I looked and saw bind can be used to run functions and other scripts this way. Here's what... (2 Replies)
Discussion started by: Azrael
2 Replies

5. Programming

get keypress c++Qt

Hi i need to get the key pressed from the keyboard without focus on the application. i work under CentOS 5.5 with QtC++ 4.7 and Python Script (0 Replies)
Discussion started by: HanyM.Magdy
0 Replies

6. Shell Programming and Scripting

Bash KeyPress (or Read Single Character)

Hi, I'm sorry if this has already been posted somewhere but I can't seem to find it on the forums (or anywhere on google :( ) I am writing a script where a user must enter a single character to perform an action. For example, Press Q to Quit or R to Refresh Basically I am stuggling... (5 Replies)
Discussion started by: Ste_Moore01
5 Replies

7. Shell Programming and Scripting

override mysqladmin drop table asking for keypress

I am trying to run this code from script. mysqladmin -u root --password='******' --socket=/tmp/mysql.sock drop ROAD_HAULAGE_TEMP Though it does what i want it asks for me to click 'y' then enter. This is not appropriate because i want it to run from cron. Can i get mysqladmin to drop a... (1 Reply)
Discussion started by: timgolding
1 Replies

8. Shell Programming and Scripting

How to trap a user keypress

Yo, I program Unix for fun- except when editing my website removed by reborg - and wanted to learn how to track, trap, and use to my advantage a user keypress. I know there is a built-in JS function that can do that, but Javascript is a client-side language, therefore not usable in Unix, and... (2 Replies)
Discussion started by: signebedi
2 Replies

9. Shell Programming and Scripting

keypress event in shell script

Hi All, How can I trap a character press in the shell script. For eg:- I have a script runinng a infinite loops , I will need to dispay menu asking for run process of to stop process and process stauts like we do in glance I have seen the traping the signal in glance command, (8 Replies)
Discussion started by: arvindng
8 Replies

10. Programming

keypress signals

How-to use keypress action signals in C? Is there any nice select or poll functions for that? (1 Reply)
Discussion started by: Esaia
1 Replies
Login or Register to Ask a Question