Context. The study of star formation is extremely challenging, due to the lack of complete and clean samples of young nearby clusters and star-forming regions. The recent Gaia DR2 catalogue complemented with the deep ground-based COSMIC DANCe catalogue offers a new database of unprecedented accuracy to revisit the membership of clusters and star-forming regions. The 30 Myr open cluster IC 4665 is one of the few well-known clusters of this age and it is an excellent target where evolutionary models can be tested and planetary formation studied. Aims. We provide a comprehensive membership analysis of IC 4665 and study the following properties: empirical isochrones, distance, magnitude distribution, present-day system mass function, and spatial distribution. Methods. We used the Gaia DR2 catalogue together with the DANCe catalogue to look for members via a probabilistic model of the distribution of the observable quantities in both the cluster and background populations. Results. We obtained a final list of 819 candidate members that cover a 12.4 magnitude range (7 < J < 19.4). We find that 50% are new candidates, and we estimate a conservative contamination rate of 20%. This unique sample of members allows us to obtain a present-day system mass function in the range of 0.02-6 M⊙, which reveals a number of details not seen in previous studies. In addition, we find that a spherically symmetric spatial distribution is favoured by our final list of members for this young open cluster. Conclusions. Our membership analysis represents a significant increase in the quantity and quality (low contamination) with respect to previous studies. It offers an excellent opportunity to revisit other fundamental parameters such as age.