Le 9 janv. 2015 à 11:19, Jean-Luc Arnaud <jean-...@cdmultimedia.fr> a écrit:

> Yes, of course!
> Your help is greatly appreciated.
> 
> May I know where these codes could be found? In the future, I could need 
> codes for other functions keys.
> 
> Many thanks.

Well, some years ago, I made my own app for that. On a window, put a listbox 
with 3 columns and an heading (“Key code”, “Key” and “Key ascii”) and a timer 
(period=1, mode=2). In the open event (in my example, in the window), have this:
  dim i As integer
  dim s As String
  
  //Fill the list with every key (for searching manually):
  for i=0 to 127 //Cover all standard keys on the keyboard
    ListMain.AddRow str(i)
    s=Keyboard.KeyName(i)
    ListMain.Cell(i,1)=s
    if len(s)=1 then //That key produces a character, so it's ASCII value is 
known
      ListMain.Cell(i,2)=str(asc(s))
    else //For other keys (backspace, tab, etc.), (1) it's better to know its 
key code (sending the ASCII value has no sense) and (2), it would mean 
rewriting.
      ListMain.Cell(i,2)="?"
    end if
  Next

In the timer.Action:
  dim i As integer
  dim j As integer
  
  //Check which keys are pressed (would fail if the key is pressed way too 
fast, but will that happen?)
  for i=0 to 126
    if Keyboard.AsyncKeyDown(i) then
      j=FindKeycode(i) //See below; looks for the entry of “i” in the list (it 
would be odd it's not in the list)
      if j=-1 then //Well, it's not in the list (?) so add it
        ListMain.AddRow str(i)
        j=ListMain.ListCount-1
        ListMain.Cell(j,1)=Keyboard.KeyName(i)
        ListMain.Cell(j,2)=str(asc(Keyboard.KeyName(i)))
      end if
      ListMain.ListIndex=j //Select the corresponding row
      do
        if not Keyboard.AsyncKeyDown(i) then Exit //Wait until the key is freed
      Loop
    end if
  Next

Function FindKeycode(KeyCode As integer) As integer
  dim i As integer
  
  if ListMain.ListCount=0 then Return -1
  for i=0 to ListMain.ListCount-1
    if ListMain.Cell(i,0)=str(KeyCode) then Return i
  Next
  Return -1
End Function

(I could send you the project or app, but it's more complicated; tell me if you 
found something to improve).
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
mbsplugins@monkeybreadsoftware.info
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Reply via email to