[Solved] How can one verify whether consecutive letters have been entered from the qwerty keyboard in a delphi console application?


Try something like this:

function HasThreeConsecutiveLetters(const Str: string): Boolean;
const
  QwertyLetters: array[0..2] of string = (
    'QWERTYUIOP',
    'ASDFGHJKL',
    'ZXCVBNM'
  );
var
  I, J, K: Integer;
  S: String;
begin
  Result := False;
  S := AnsiUpperCase(Str);
  for I := 1 to Length(S) do
  begin
    for J := Low(QwertyLetters) to High(QwertyLetters) do
    begin
      K := Pos(S[I], QwertyLetters[J]);
      if (K <> 0) and
         ((K+2) <= Length(QwertyLetters[J])) and
         (Copy(S, I, 3) = Copy(QwertyLetters[J], K, 3)) then
      begin
        Result := True;
        Exit;
      end;
    end;
  end;
end;

Then you can do this:

var
  input: string;
begin
  input := ...;
  if HasThreeConsecutiveLetters(input) then
    ...
  else
    ...
end;

solved How can one verify whether consecutive letters have been entered from the qwerty keyboard in a delphi console application?