Du musst nur wissen, was du willst.
So kann z.B. eine Tastaturschnittstelle ausehen:
Delphi-Quellcode:
procedure TDemoForm.ListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
s: string;
i: Integer;
begin
with Sender as TListBox do
case Key of
VK_INSERT:
begin
s := '';
if InputQuery('Hinzufügen', 'Text', s) then
if Trim(s) <> '' then
Items.Insert(ItemIndex, s);
end;
VK_DELETE:
if ItemIndex > -1 then
Items.Delete(ItemIndex);
VK_SPACE:
begin
s := Items[ItemIndex];
if InputQuery('Bearbeiten', 'Text', s) then
if Trim(s) <> '' then
Items[ItemIndex] := s;
end;
VK_UP:
if (ItemIndex > 0) and (ssCtrl in Shift) then
begin
i := ItemIndex;
Items.Exchange(Pred(ItemIndex), ItemIndex);
ItemIndex := i;
end;
VK_DOWN:
if (Succ(ItemIndex) < Count) and (ssCtrl in Shift) then
begin
i := ItemIndex;
Items.Exchange(Succ(ItemIndex), ItemIndex);
ItemIndex := i;
end;
end;
// Key := 0;
end;