you can attach keyboard event to svg elements . but along with keyboard down you have to attach focus event without attaching focus it does't works.
var chart = d3.select("#chart")
.style("fill", "red")
.style("height", '600px')
var svg = chart.append("svg")
.attr("width", 500)
.attr("height", 300);
var currentObject = null;
svg.append("circle")
.attr("class","selectme").attr("id","circle")
.attr("cx",50).attr("cy",50).attr("r",45)
.style("fill","lightblue");
svg.append("rect")
.attr("class","selectme").attr("id","rectangle")
.attr({"x":10,"y":150,"width":150,"height":100})
.style("fill","lightgreen");
d3.selectAll(".selectme")
.on("mouseover", function() {
d3.select(this).style("stroke","black");
currentObject = this;
})
.on("mouseout", function() {
d3.select(this).style("stroke","none");
currentObject = null;
});
d3.select("svg")
.on("keydown", function() {
svg.append("text")
.attr("x","5")
.attr("y","130")
.style("font-size","20px")
.text("keyCode: " + d3.event.keyCode + " applied to : " + (currentObject===null ? "nothing!" : currentObject.id))
.transition().duration(2000)
.style("font-size","5px")
.style("fill-opacity",".1")
.remove();
}).on("focus", function(){});