Erratic capacitive touch sensor values

Try this test sketch.
Tried on an Uno R3 with just a 10Megohm resistor between D8 and GND.
Code lights the built-in LED when D8 is touched.
Leo..

const byte ledPin = 13;
unsigned long triggerTime;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (digitalRead(8)) triggerTime = millis();
  digitalWrite (ledPin, millis() - triggerTime < 50);
}