There are many ways to do this but here's a quick proof of concept that shows one approach. Here I wait until the route directions have been generated. Once they are ready I use the Geolocation API to find the current location then check and see if that location is contained within the extent of any of the route features. If it is then I can access the route directions for that feature. For other ways of testing to see if the point is on the route line look into performing a spatial query or using the geometryService (intersect, touches etc) methods.
on(directionsWidget, "directions-finish", function(e){
var routeFeatures = directionsWidget.directions.features;
navigator.geolocation.watchPosition(function(position){
locationLayer.clear(); //clear existing location graphic
var location = new Point(position.coords);
//Add a test point on the map so we can see the current location
locationLayer.add(new Graphic(location, new SimpleMarkerSymbol()));
array.forEach(routeFeatures, function(routeFeature){
var featureExtent = routeFeature.geometry.getExtent();
if(featureExtent.contains(location)){
console.log("Feature within route extent");
//Add the extent graphic for testing so we can see when
// our location is within the extent envelope
locationLayer.add(new Graphic(featureExtent, new SimpleFillSymbol()));
var directions = routeFeature.attributes.text;
var turnType = routeFeature.attributes.maneuverType;
console.log(directions + " " + turnType);
}
});
});
});