replacing serial.Read input by digital.Read

Hello,

I have following code

String inputBuffer = "";
  while (inputBuffer != "ok") {
    inputBuffer = "";
    while (Serial.available() > 0) {
      char ch = Serial.read();
      inputBuffer += ch; 
      delay (10);

This is the input() function that makes that other part of the code is realised when string 'ok' is written in serial monitor. How to achieve the same but not by writing anything, but by pressing a pushbutton?

You need to post the complete program so we cn see the whole context.

Do you want to replace the Serial input completely or do you want to the pushbutton to operate alongside the serial input?

...R

Look at digitalRead examples and probably the state change detection example.